Skip to content

Instantly share code, notes, and snippets.

@tomislater
Last active December 17, 2015 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomislater/5595324 to your computer and use it in GitHub Desktop.
Save tomislater/5595324 to your computer and use it in GitHub Desktop.
Script for uploads code on gitst. For BPython.
#!/usr/bin/env python
import sys
import json
import requests
def do_gist_json(s):
""" Use json to post to github. """
gist_url = 'https://api.github.com/gists'
data = {'description': "Gist from BPython",
'public': True,
'files': {
'sample.py': {'content': None}
}}
data['files']['sample.py']['content'] = s
res = requests.post(gist_url,
data=json.dumps(data),
auth=("user", "pass"))
return res.json()["html_url"]
if __name__ == "__main__":
s = sys.stdin.read()
print do_gist_json(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment