Skip to content

Instantly share code, notes, and snippets.

@rahulbanerjee26
Created September 25, 2022 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahulbanerjee26/6bf4249c5eb01b79702378ecf9448a32 to your computer and use it in GitHub Desktop.
Save rahulbanerjee26/6bf4249c5eb01b79702378ecf9448a32 to your computer and use it in GitHub Desktop.
def createGists(token, snippets, public=False):
query_url = "https://api.github.com/gists"
headers = {"Authorization": f"token {token}"}
urls = []
for fileName, code in snippets:
data = {"public": public, "files": {fileName: {"content": code}}}
# Send the request
response = requests.post(query_url, headers=headers, data=json.dumps(data))
if response.status_code == 201:
urls.append(response.json()["html_url"])
return urls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment