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