From e4b236158cdefbe65b8f8768f441e3a8a0d5641f Mon Sep 17 00:00:00 2001 From: Redume Date: Wed, 18 Sep 2024 21:27:26 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20=D1=80?= =?UTF-8?q?=D0=B5=D0=B4=D0=B8=D1=80=D0=B5=D0=BA=D1=82=20404=20=D0=BE=D1=88?= =?UTF-8?q?=D0=B8=D0=B1=D0=BA=D0=B8,=20=D0=B5=D1=81=D0=BB=D0=B8=20=D0=BD?= =?UTF-8?q?=D0=B5=D1=82=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routes/wallpaper.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/routes/wallpaper.py b/src/routes/wallpaper.py index ed86bd1..24adbd4 100644 --- a/src/routes/wallpaper.py +++ b/src/routes/wallpaper.py @@ -1,5 +1,5 @@ from fastapi import APIRouter, Request -from fastapi.responses import HTMLResponse +from fastapi.responses import HTMLResponse, FileResponse from fastapi.templating import Jinja2Templates import requests @@ -11,12 +11,14 @@ template = Jinja2Templates(directory='./src/web/html') @router.get('/wallpaper/{day}', response_class=HTMLResponse) async def wallpaper(request: Request, day): - token = '1gI9G84ZafKDEnrbydviGknReOGiVK9jqrQBE3et' res = requests.get('https://api.nasa.gov/planetary/apod', params={ 'api_key': '1gI9G84ZafKDEnrbydviGknReOGiVK9jqrQBE3et', 'date': day, }) + if res.status_code != 200: + return FileResponse('./src/web/html/error/404.html') + return template.TemplateResponse( request, '/wallpaper.html',