feat(api): add multiple days api
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user