Skip to content

Instantly share code, notes, and snippets.

@WannaBeGeekster
Created March 31, 2018 12:22
Show Gist options
  • Save WannaBeGeekster/923881825d52e9a3ab171b364bbd7318 to your computer and use it in GitHub Desktop.
Save WannaBeGeekster/923881825d52e9a3ab171b364bbd7318 to your computer and use it in GitHub Desktop.
Freds Gist
# Virtual event handlers, overide them in your derived class
def SaveNewGist(self, event):
self.gist_content = self.scinNewGistContents.GetText()
self.new_gist_name = self.txtCtrlNewGistName.GetValue()
self.new_gist_file_name = self.txtCtrlNewGistFileName.GetValue()
self.public = self.chkPublic.GetValue()
data = {}
data['description'] = self.new_gist_name
if self.public:
data['public'] = true
else:
data['public'] = false
data['files'] = {}
data['files'][self.new_gist_file_name] = {}
data['files'][self.new_gist_file_name]['content'] = self.gist_content
json_data = json.dumps(data)
r = requests.post('https://api.github.com/gists', data=json_data)
if r.status_code == 200:
json_result = json.loads(r.text)
print(json_result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment