change condition statuscode
Some checks failed
Create and publish a Docker image / build-and-push-image (push) Has been cancelled

This commit is contained in:
Данил 2024-09-30 17:26:44 +03:00
parent c3918c3d35
commit c801396953

View file

@ -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(