refactor(weather): add app_build method

This commit is contained in:
2024-07-28 20:26:38 +03:00
parent 48a6cce569
commit 1fb627110d
12 changed files with 254 additions and 199 deletions

View File

@@ -1,12 +1,13 @@
import datetime
from fastapi import FastAPI
from fastapi import FastAPI, Request
from weather.api import get_api
from weather.model import WeatherResponse
def mount(app: FastAPI):
@app.get("/api/weather/{location}/{date}")
async def get_weather(location: str, date: datetime.date) -> WeatherResponse:
return await get_api().get_day(location, date)
async def get_weather_api(
request: Request, location: str, date: datetime.date
) -> WeatherResponse:
return await request.app.state.weather_api.get_day(location, date)