From c801396953f4b186ee9118107cc38ee2500f9359 Mon Sep 17 00:00:00 2001 From: Redume Date: Mon, 30 Sep 2024 17:26:44 +0300 Subject: [PATCH] change condition statuscode --- src/routes/wallpaper.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/routes/wallpaper.py b/src/routes/wallpaper.py index 21aa73b..79273a3 100644 --- a/src/routes/wallpaper.py +++ b/src/routes/wallpaper.py @@ -16,9 +16,8 @@ async def today_wallpaper(request: Request): date = datetime.today().strftime('%Y-%m-%d') res = requests.get(f'https://api.starlio.space/last') - if not HTTPStatus(res.status_code).is_redirection or \ - not HTTPStatus(res.status_code).is_success: - + if HTTPStatus(res.status_code).is_server_error or \ + HTTPStatus(res.status_code).is_client_error: return FileResponse('./src/web/html/error/404.html') return RedirectResponse(f'/wallpaper/{date}') @@ -28,8 +27,8 @@ async def today_wallpaper(request: Request): async def wallpaper(request: Request, day): res = requests.get(f'https://api.starlio.space/wallpaper/{day}') - if not HTTPStatus(res.status_code).is_redirection or \ - not HTTPStatus(res.status_code).is_success: + if HTTPStatus(res.status_code).is_server_error or \ + HTTPStatus(res.status_code).is_client_error: return FileResponse('./src/web/html/error/404.html') return template.TemplateResponse(