mirror of
https://github.com/Starlio-app/Starlio-web.git
synced 2024-11-24 17:36:21 +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')
|
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)
|
@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')
|
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:
|
if res.status_code != 200:
|
||||||
return FileResponse('./src/web/html/error/404.html')
|
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)
|
@router.get('/wallpaper/{day}', response_class=HTMLResponse)
|
||||||
async def wallpaper(request: Request, day):
|
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:
|
if res.status_code != 200:
|
||||||
return FileResponse('./src/web/html/error/404.html')
|
return FileResponse('./src/web/html/error/404.html')
|
||||||
|
|
Loading…
Add table
Reference in a new issue