23 lines
741 B
Python
23 lines
741 B
Python
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}/day/{date}")
|
|
async def get_api_weather_day(
|
|
request: Request, location: str, date: datetime.date
|
|
) -> WeatherResponse:
|
|
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)
|