19 lines
557 B
Python
19 lines
557 B
Python
import requests
|
|
import json
|
|
|
|
# Define your JSON object
|
|
my_json = {'name': 'John', 'age': 30, 'city': 'New York'}
|
|
|
|
# Define the API endpoint for Hastebin
|
|
hastebin_url = 'https://hastebin.com/documents'
|
|
|
|
# Upload the JSON object to Hastebin and get the URL
|
|
response = requests.post(hastebin_url, data=json.dumps(my_json))
|
|
if response.status_code == 200:
|
|
key = response.json()['key']
|
|
hastebin_url = f'https://hastebin.com/{key}'
|
|
print(f'JSON object uploaded to Hastebin: {hastebin_url}')
|
|
else:
|
|
print('Error uploading JSON object to Hastebin')
|
|
|