Last active
December 17, 2015 10:29
-
-
Save tomislater/5595324 to your computer and use it in GitHub Desktop.
Script for uploads code on gitst. For BPython.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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