Created
September 25, 2022 22:35
-
-
Save rahulbanerjee26/6bf4249c5eb01b79702378ecf9448a32 to your computer and use it in GitHub Desktop.
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
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