Фикс, поменял апи, pep8

This commit is contained in:
Данил 2024-09-27 18:03:53 +03:00
parent dd0f533e4c
commit 83355a6f41

View file

@ -9,16 +9,11 @@ router = APIRouter()
template = Jinja2Templates(directory='./src/web/html')
def get_wallpaper(date: str):
return requests.get('https://api.nasa.gov/planetary/apod', params={
'api_key': '1gI9G84ZafKDEnrbydviGknReOGiVK9jqrQBE3et',
'date': date,
})
@router.get('/wallpaper/today', response_class=HTMLResponse)
async def today_wallpaper(requests: Request):
async def today_wallpaper(request: Request):
date = datetime.today().strftime('%Y-%m-%d')
res = get_wallpaper(date)
res = requests.get(f'https://api.starlio.space/wallpaper/last')
if res.status_code != 200:
return FileResponse('./src/web/html/error/404.html')
@ -28,7 +23,8 @@ async def today_wallpaper(requests: Request):
@router.get('/wallpaper/{day}', response_class=HTMLResponse)
async def wallpaper(request: Request, day):
res = get_wallpaper(day)
res = requests.get(f'https://api.starlio.space/wallpaper/{day}')
print(res)
if res.status_code != 200:
return FileResponse('./src/web/html/error/404.html')
@ -37,4 +33,4 @@ async def wallpaper(request: Request, day):
request,
'/wallpaper.html',
{'info': res.json()}
)
)