2023-04-04 09:15:28 +03:00
|
|
|
import requests
|
|
|
|
import json
|
|
|
|
import hashlib
|
|
|
|
|
2023-04-04 22:55:16 +03:00
|
|
|
|
|
|
|
URL = 'https://pastie.io/documents'
|
|
|
|
NAME = 'pastie'
|
|
|
|
|
|
|
|
def get_service_tag():
|
|
|
|
return NAME
|
|
|
|
|
2023-04-04 09:15:28 +03:00
|
|
|
def upload(data):
|
|
|
|
try:
|
|
|
|
json_data = json.dumps(data)
|
|
|
|
md5sum = hashlib.md5(json_data.encode('utf-8')).hexdigest()
|
|
|
|
response = requests.post('https://pastie.io/documents', data=json_data)
|
|
|
|
if response.status_code == 200:
|
|
|
|
key = response.json()['key']
|
|
|
|
pastie_url = f'https://pastie.io/{key}'
|
|
|
|
# print(f'JSON object uploaded to Pastie: {pastie_url}')
|
|
|
|
|
|
|
|
return {
|
2023-04-04 22:55:16 +03:00
|
|
|
"service": NAME,
|
|
|
|
"name": NAME + '_' + key,
|
2023-04-04 09:15:28 +03:00
|
|
|
"key": pastie_url,
|
|
|
|
"md5sum": md5sum
|
|
|
|
}
|
|
|
|
else:
|
|
|
|
return None
|
|
|
|
except requests.exceptions.RequestException:
|
|
|
|
return None
|
|
|
|
|