feat(api): add multiple days api

This commit is contained in:
2024-07-29 21:42:44 +03:00
parent 22fab7a15a
commit 7f0e19fb5a
16 changed files with 5411 additions and 64 deletions

View File

@@ -2,12 +2,21 @@ import datetime
from fastapi import FastAPI, Request
from weather.api import WeatherApi
from weather.model import WeatherResponse
def mount(app: FastAPI):
@app.get("/api/weather/{location}/{date}")
async def get_weather_api(
@app.get("/api/weather/{location}/day/{date}")
async def get_api_weather_day(
request: Request, location: str, date: datetime.date
) -> WeatherResponse:
return await request.app.state.weather_api.get_day(location, date)
weather_api: WeatherApi = request.app.state.weather_api
return await weather_api.get_day(location, date)
@app.get("/api/weather/{location}/days/{days}")
async def get_api_weather_days(
request: Request, location: str, days: int
) -> WeatherResponse:
weather_api: WeatherApi = request.app.state.weather_api
return await weather_api.get_days(location, days)