import requests
import base64
import json
def constructURL(user = "404",repo_name= "404",path_to_file= "404",url= "404"):
url = url.replace("{user}",user)
url = url.replace("{repo_name}",repo_name)
url = url.replace("{path_to_file}",path_to_file)
return url
user = '<provide value>'
repo_name = '<provide value>'
path_to_file = '<provide value>'
json_url ='https://api.github.com/repos/{user}/{repo_name}/contents/{path_to_file}'
json_url = constructURL(user,repo_name,path_to_file,json_url)
response = requests.get(json_url)
if response.status_code == requests.codes.ok:
jsonResponse = response.json()
content = base64.b64decode(jsonResponse['content'])
jsonString = content.decode('utf-8')
finalJson = json.loads(jsonString)
else:
print('Content was not found.')
for key, value in finalJson.items():
print("The key and value are ({}) = ({})".format(key, value))