From 2f505d6e5a3e99cf6f54703d03b19bd434e74793 Mon Sep 17 00:00:00 2001 From: Redume Date: Sat, 14 Sep 2024 21:06:34 +0300 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20=D1=88?= =?UTF-8?q?=D0=B0=D0=B1=D0=BB=D0=BE=D0=B0=D0=BD,=20=D0=BF=D0=BE=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D1=8F=D0=BB=20=D0=BC=D0=B5=D1=82=D0=B0=20=D1=82?= =?UTF-8?q?=D1=8D=D0=B3=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routes/wallpaper.py | 25 +++++++++++++++++++++++++ src/web/html/wallpaper.html | 22 ++++++++++++---------- 2 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 src/routes/wallpaper.py diff --git a/src/routes/wallpaper.py b/src/routes/wallpaper.py new file mode 100644 index 0000000..2f1b73e --- /dev/null +++ b/src/routes/wallpaper.py @@ -0,0 +1,25 @@ +from fastapi import APIRouter, Request +from fastapi.responses import HTMLResponse +from fastapi.templating import Jinja2Templates + +import requests + +router = APIRouter() + +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, + }) + + print(res.json()) + + return template.TemplateResponse( + request, + '/wallpaper.html', + {'info': res.json()} + ) \ No newline at end of file diff --git a/src/web/html/wallpaper.html b/src/web/html/wallpaper.html index e9649ac..4ed0cc1 100644 --- a/src/web/html/wallpaper.html +++ b/src/web/html/wallpaper.html @@ -13,12 +13,15 @@ - + + - - - + + + + + @@ -32,13 +35,13 @@
- Spiral Aurora over Iceland + {{info.title}}
-

Spiral Aurora over Iceland

- -

The scene may look like a fantasy, but it's really Iceland. The rock arch is named Gatklettur and located on the island's northwest coast. Some of the larger rocks in the foreground span a meter across. The fog over the rocks is really moving waves averaged over long exposures. The featured image is a composite of several foreground and background shots taken with the same camera and from the same location on the same night last November. The location was picked for its picturesque foreground, but the timing was planned for its colorful background: aurora. The spiral aurora, far behind the arch, was one of the brightest seen in the astrophotographer's life. The coiled pattern was fleeting, though, as auroral patterns waved and danced for hours during the cold night. Far in the background were the unchanging stars, with Earth's rotation causing them to appear to slowly circle the sky's northernmost point near Polaris.

+

{{info.title}}

+ +

{{info.explanation}}

- \ No newline at end of file