import datetime from fastapi import FastAPI from gallery.easel.core import AppRequest from gallery.sketch.weather.model import Location, WeatherResponse def mount(app: FastAPI): @app.get("/api/weather/locations", tags=["API"]) async def get_api_weather_locations(request: AppRequest, query: str) -> list[Location]: weather_api = request.app.state.api.weather return await weather_api.find_locations(query) @app.get("/api/weather/{location}/day/{date}", tags=["API"]) async def get_api_weather_day(request: AppRequest, location: str, date: datetime.date) -> WeatherResponse: weather_api = request.app.state.api.weather return await weather_api.get_day(location, date) @app.get("/api/weather/{location}/days/{days}", tags=["API"]) async def get_api_weather_days(request: AppRequest, location: str, days: int) -> WeatherResponse: weather_api = request.app.state.api.weather return await weather_api.get_days(location, days)