Fix bug with if statements
parent
e25c048717
commit
ca5dc87e82
9
api.py
9
api.py
|
@ -49,14 +49,9 @@ async def set_badge(repo: str, new_badge: str, branch: str=None, action: str=Non
|
||||||
|
|
||||||
@app.get("/get_badge/")
|
@app.get("/get_badge/")
|
||||||
async def get_badge(repo: str, branch: str=None, action: str=None):
|
async def get_badge(repo: str, branch: str=None, action: str=None):
|
||||||
if branch is None and action is None and repo not in badge_dict.keys():
|
if (repo, branch, action) not in badge_dict.keys() or repo not in badge_dict.keys():
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_404_NOT_FOUND,
|
status_code=status.HTTP_404_NOT_FOUND,
|
||||||
detail="Repo not found",
|
detail="Badge not found",
|
||||||
)
|
|
||||||
elif (repo, branch, action) not in badge_dict.keys():
|
|
||||||
raise HTTPException(
|
|
||||||
status_code=status.HTTP_404_NOT_FOUND,
|
|
||||||
detail="Repo not found",
|
|
||||||
)
|
)
|
||||||
return RedirectResponse("https://img.shields.io/badge/" + (badge_dict[repo, branch, action] if branch is not None or action is not None else badge_dict[repo]))
|
return RedirectResponse("https://img.shields.io/badge/" + (badge_dict[repo, branch, action] if branch is not None or action is not None else badge_dict[repo]))
|
||||||
|
|
Loading…
Reference in New Issue