Better organization of them files. Added bpa.st support (paste.python.org).
This commit is contained in:
41
not_working/centos_paste.py
Normal file
41
not_working/centos_paste.py
Normal file
@ -0,0 +1,41 @@
|
||||
import requests
|
||||
|
||||
def paste_to_centos(text, title=None, name=None, private=False, lang=None, expire=None):
|
||||
"""
|
||||
Paste text to paste.centos.org and return the URL of the created paste.
|
||||
|
||||
:param text: The content to paste (required)
|
||||
:param title: Title for the paste (optional)
|
||||
:param name: Author's name (optional)
|
||||
:param private: Make paste private if True (optional)
|
||||
:param lang: Language for syntax highlighting (optional)
|
||||
:param expire: Expiration time in minutes (optional)
|
||||
:return: URL of the created paste or error message
|
||||
"""
|
||||
url = "https://paste.centos.org/api/create"
|
||||
|
||||
data = {
|
||||
"text": text
|
||||
}
|
||||
|
||||
if title:
|
||||
data["title"] = title
|
||||
if name:
|
||||
data["name"] = name
|
||||
if private:
|
||||
data["private"] = 1
|
||||
if lang:
|
||||
data["lang"] = lang
|
||||
if expire:
|
||||
data["expire"] = expire
|
||||
|
||||
response = requests.post(url, data=data)
|
||||
|
||||
if response.status_code == 200:
|
||||
return response.text.strip() # Return the paste URL
|
||||
else:
|
||||
return f"Error: {response.text.strip()}"
|
||||
|
||||
# Example usage:
|
||||
# result = paste_to_centos("This is a test paste", title="Test", name="John Doe", lang="python")
|
||||
# print(result)
|
28
not_working/debian_paste.py
Normal file
28
not_working/debian_paste.py
Normal file
@ -0,0 +1,28 @@
|
||||
import requests
|
||||
|
||||
def upload_to_paste_debian(content: str) -> str:
|
||||
# The URL for the paste service
|
||||
url = 'https://paste.debian.net/'
|
||||
|
||||
# Data payload
|
||||
data = {
|
||||
'format': 'text', # You can also use 'text' if you want to enforce plain text format
|
||||
'content': content,
|
||||
'submit': 'Send'
|
||||
}
|
||||
|
||||
# Send the POST request to paste.debian.net
|
||||
response = requests.post(url, data=data)
|
||||
|
||||
|
||||
|
||||
# Check if the request was successful
|
||||
if response.status_code == 200:
|
||||
# If successful, extract the paste URL from the response
|
||||
print(response.content)
|
||||
paste_url = response.url
|
||||
return paste_url
|
||||
else:
|
||||
raise Exception(f"Failed to upload to paste.debian.net, status code: {response.status_code}")
|
||||
|
||||
|
42
not_working/pastesh.py
Normal file
42
not_working/pastesh.py
Normal file
@ -0,0 +1,42 @@
|
||||
import tempfile
|
||||
import secrets
|
||||
import requests
|
||||
import os
|
||||
|
||||
def publish_to_pastesh(content):
|
||||
HOST = 'https://paste.sh'
|
||||
VERSION = 'v2'
|
||||
|
||||
# Generate ID
|
||||
id = f"p{secrets.token_urlsafe(6)}"
|
||||
|
||||
# Create a temporary file
|
||||
with tempfile.NamedTemporaryFile(mode='w+', delete=False) as temp_file:
|
||||
temp_file_path = temp_file.name
|
||||
|
||||
# Write content to the temporary file
|
||||
temp_file.write(content)
|
||||
temp_file.flush()
|
||||
|
||||
try:
|
||||
# Prepare headers
|
||||
headers = {
|
||||
'X-Server-Key': '',
|
||||
'Content-type': f'text/vnd.paste.sh-{VERSION}'
|
||||
}
|
||||
|
||||
# Send the request
|
||||
with open(temp_file_path, 'rb') as file:
|
||||
response = requests.post(f"{HOST}/{id}", headers=headers, data=file)
|
||||
|
||||
if response.status_code == 200:
|
||||
return f"{HOST}/{id}"
|
||||
else:
|
||||
print(f"Error: Status code {response.status_code}")
|
||||
print(f"Response: {response.text}")
|
||||
return None
|
||||
|
||||
finally:
|
||||
# Clean up the temporary file
|
||||
os.unlink(temp_file_path)
|
||||
|
Reference in New Issue
Block a user