Created
May 31, 2017 15:19
-
-
Save QuantTraderEd/528bc5c76183eec7d3ecc1dc29502677 to your computer and use it in GitHub Desktop.
scipt what upload file to gist
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
# -*- coding: utf-8 -*- | |
import json | |
filename = 'pgist.py' | |
# 1. make content | |
with open(filename, 'r') as f: | |
line_lst = f.readlines() | |
f.close() | |
content = ''.join(line_lst) | |
# 2. Build the JSON request | |
data_dict = {} | |
data_dict['description'] = 'scipt what upload file to gist' | |
data_dict['public'] = True | |
data_dict['files'] = {filename:{"content":content}} | |
with open('data.json', 'w+') as fp: | |
json.dump(data_dict, fp) | |
fp.close() | |
# 3. Upload file to gist | |
# curl --user "QuantTraderEd" --request POST --data @data.json https://api.github.com/gists |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment