mirror of
https://github.com/Starlio-app/Starlio-web.git
synced 2025-03-03 22:41:25 +03:00
fix: set 3s timeout for request api
This commit is contained in:
parent
058c9771df
commit
a1baf74e8d
1 changed files with 2 additions and 2 deletions
|
@ -32,7 +32,7 @@ async def today_wallpaper(request: Request):
|
||||||
Returns:
|
Returns:
|
||||||
HTMLResponse: The wallpaper page or 404 error page.
|
HTMLResponse: The wallpaper page or 404 error page.
|
||||||
"""
|
"""
|
||||||
res = requests.get(f'https://api.starlio.space/last')
|
res = requests.get(f'https://api.starlio.space/last', timeout=3)
|
||||||
|
|
||||||
if HTTPStatus(res.status_code).is_server_error or HTTPStatus(res.status_code).is_client_error:
|
if HTTPStatus(res.status_code).is_server_error or HTTPStatus(res.status_code).is_client_error:
|
||||||
return FileResponse('../web/html/error/404.html', status_code=HTTPStatus.NOT_FOUND)
|
return FileResponse('../web/html/error/404.html', status_code=HTTPStatus.NOT_FOUND)
|
||||||
|
@ -57,7 +57,7 @@ async def wallpaper(request: Request, day):
|
||||||
Returns:
|
Returns:
|
||||||
HTMLResponse: The wallpaper page or 404 error page.
|
HTMLResponse: The wallpaper page or 404 error page.
|
||||||
"""
|
"""
|
||||||
res = requests.get(f'https://api.starlio.space/wallpaper/{day}')
|
res = requests.get(f'https://api.starlio.space/wallpaper/{day}', timeout=3)
|
||||||
|
|
||||||
if (HTTPStatus(res.status_code).is_server_error
|
if (HTTPStatus(res.status_code).is_server_error
|
||||||
or HTTPStatus(res.status_code).is_client_error
|
or HTTPStatus(res.status_code).is_client_error
|
||||||
|
|
Loading…
Add table
Reference in a new issue