Skip to content

Instantly share code, notes, and snippets.

@BlogBlocks
Last active July 18, 2018 03:49
Show Gist options
  • Select an option

  • Save BlogBlocks/71cd9394db91fd089765861ebf121b0e to your computer and use it in GitHub Desktop.

Select an option

Save BlogBlocks/71cd9394db91fd089765861ebf121b0e to your computer and use it in GitHub Desktop.
#!/usr/bin/python
#USE: python SimpleGistPost.py FileToPost.py
import os, requests, sys, json
import GISTkey
from time import sleep
username=GISTkey.gistkey()[0]
password=GISTkey.gistkey()[1]
filename = os.path.basename(sys.argv[1])
content=open(filename, 'r').read()
r = requests.post('https://api.github.com/gists',json.dumps({'files':{filename:{"content":content}}}),auth=requests.auth.HTTPBasicAuth(username, password))
sleep(2)
print(r.json()['html_url'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment