From 94c5c41846bc8a9a715d786057b1ef5f1aefc7ce Mon Sep 17 00:00:00 2001 From: Charlie Taylor Date: Wed, 30 Oct 2024 23:29:15 -0700 Subject: [PATCH] formatting + typing --- main.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index f9dafe3..2edc200 100644 --- a/main.py +++ b/main.py @@ -207,7 +207,9 @@ def winner_admin_page( @app.get("/win/{pic_id}") -def set_winner(pic_id: int, password: Annotated[str | None, Cookie()] = None): +def set_winner( + pic_id: int, password: Annotated[str | None, Cookie()] = None +) -> RedirectResponse: if not is_logged_in(password): raise HTTPException(status_code=401, detail="Unauthorized") @@ -216,8 +218,11 @@ def set_winner(pic_id: int, password: Annotated[str | None, Cookie()] = None): raise HTTPException(status_code=404, detail="Pic not found") + @app.post("/prompt") -async def create_prompt(request: Request, password: Annotated[str | None, Cookie()] = None) -> RedirectResponse: +async def create_prompt( + request: Request, password: Annotated[str | None, Cookie()] = None +) -> RedirectResponse: if not is_logged_in(password): raise HTTPException(status_code=401, detail="Unauthorized") @@ -227,8 +232,9 @@ async def create_prompt(request: Request, password: Annotated[str | None, Cookie raise HTTPException(status_code=400, detail="No prompt provided") db.create_prompt(prompt) - + return RedirectResponse(url="/admin", status_code=303) -def is_logged_in(password: str | None): + +def is_logged_in(password: str | None) -> bool: return password is not None and password == settings.admin_pass