Skip to content

Instantly share code, notes, and snippets.

@Ramko9999
Created April 22, 2021 20:50
Show Gist options
  • Select an option

  • Save Ramko9999/8b038dbd082caa77516217bc97e810a7 to your computer and use it in GitHub Desktop.

Select an option

Save Ramko9999/8b038dbd082caa77516217bc97e810a7 to your computer and use it in GitHub Desktop.
@app.route("/projects", methods=["GET"])
def getRepos():
try:
url = "https://api.github.com/users/Ramko9999/repos"
headers = {"Accept":"application/vnd.github.mercy-preview+json"}
repos = requests.get(url, headers=headers, auth=(USERNAME,TOKEN)).json()
projects = []
for repo in repos:
if repo["homepage"]:
project = {
"id": repo["id"],
"name": repo["name"],
"url": repo["html_url"],
"description": repo["description"],
"topics":repo["topics"],
"images": repo["homepage"].split(";")
}
projects.append(project)
return {"projects": projects, "error": False}
except Exception as e:
return {"error": True, "message": str(e)}, 500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment