mpaste/not_working/debian_paste.py

29 lines
782 B
Python
Raw Permalink Normal View History

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}")