import requests
import json
url = 'https://snippets.glot.io/snippets'
headers = {
'Authorization': 'a9d83a42-73bb-473b-b19e-4d57c1961c49',
'Content-type': 'application/json'
}
data = {
"language": "python",
"title": "POST final version",
"public": True,
"files": [
{
"name": "POST.py",
"content": open('main.py').read()
}
]
}
res = requests.post(url, data=json.dumps(data), headers=headers)
paste = json.loads(res.text)
print('ID : '+ paste['id'])
print('URL : '+ paste['url'])