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') date = datetime.today().strftime('%Y-%m-%d')
res = requests.get(f'https://api.starlio.space/last') res = requests.get(f'https://api.starlio.space/last')
if not HTTPStatus(res.status_code).is_redirection or \ if HTTPStatus(res.status_code).is_server_error or \
not HTTPStatus(res.status_code).is_success: HTTPStatus(res.status_code).is_client_error:
return FileResponse('./src/web/html/error/404.html') return FileResponse('./src/web/html/error/404.html')
return RedirectResponse(f'/wallpaper/{date}') return RedirectResponse(f'/wallpaper/{date}')
@ -28,8 +27,8 @@ async def today_wallpaper(request: Request):
async def wallpaper(request: Request, day): async def wallpaper(request: Request, day):
res = requests.get(f'https://api.starlio.space/wallpaper/{day}') res = requests.get(f'https://api.starlio.space/wallpaper/{day}')
if not HTTPStatus(res.status_code).is_redirection or \ if HTTPStatus(res.status_code).is_server_error or \
not HTTPStatus(res.status_code).is_success: HTTPStatus(res.status_code).is_client_error:
return FileResponse('./src/web/html/error/404.html') return FileResponse('./src/web/html/error/404.html')
return template.TemplateResponse( return template.TemplateResponse(