Skip to content

Instantly share code, notes, and snippets.

@QuantTraderEd
Created May 31, 2017 15:19
Show Gist options
  • Save QuantTraderEd/528bc5c76183eec7d3ecc1dc29502677 to your computer and use it in GitHub Desktop.
Save QuantTraderEd/528bc5c76183eec7d3ecc1dc29502677 to your computer and use it in GitHub Desktop.
scipt what upload file to gist
# -*- 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