mirror of
https://github.com/Starlio-app/Starlio-web.git
synced 2024-12-25 01:43:44 +03:00
Фикс, поменял апи, pep8
This commit is contained in:
parent
dd0f533e4c
commit
83355a6f41
1 changed files with 5 additions and 9 deletions
|
@ -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()}
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue