Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
45 lines (33 sloc) 1.1 KB
#!/usr/bin/env python
import sys
import urllib2
import json
def do_gist_json(s):
""" use json to post to github"""
# or use: curl -X POST -d '{"public":true,"files":{"BPython Gist":{"content":"String file contents"}}}'
gist_confirm = True
gist_private = False
gist_url = ''
gist_show_url = '$gist_id'
data = {'description': None,
'public': None,
'files' : {
'sample': { 'content': None }
data['description'] = 'Gist from BPython'
data['public'] = gist_private
data['files']['sample']['content'] = s
req = urllib2.Request(gist_url, json.dumps(data), {'Content-Type': 'application/json'})
res = urllib2.urlopen(req)
except HTTPError, e:
return e
json_res = json.loads(
gist_url = json_res['html_url']
except HTTPError, e:
return e
return gist_url
if __name__ == "__main__":
s =
print do_gist_json(s)