refactor(weather): add app_build method
This commit is contained in:
@@ -1,27 +1,22 @@
|
||||
import locale
|
||||
from os import environ
|
||||
|
||||
import uvicorn
|
||||
from fastapi import FastAPI
|
||||
|
||||
from gismeteo.api import GismeteoApi
|
||||
from weather.api import WeatherApi
|
||||
|
||||
from . import api as _api
|
||||
from .route import api, doc, view
|
||||
|
||||
_api.DEFAULT_API = GismeteoApi()
|
||||
|
||||
locale.setlocale(locale.LC_TIME, "ru_RU.UTF-8")
|
||||
def build_app(weather_api: WeatherApi) -> FastAPI:
|
||||
locale.setlocale(locale.LC_TIME, "ru_RU.UTF-8")
|
||||
|
||||
app = FastAPI(
|
||||
title="Weather",
|
||||
docs_url=None,
|
||||
redoc_url=None,
|
||||
)
|
||||
doc.mount(app)
|
||||
api.mount(app)
|
||||
view.mount(app)
|
||||
|
||||
|
||||
def run():
|
||||
uvicorn.run("weather.app:app", host="0.0.0.0", port=8000, reload="DEBUG" in environ)
|
||||
app = FastAPI(
|
||||
title="Weather",
|
||||
docs_url=None,
|
||||
redoc_url=None,
|
||||
)
|
||||
app.state.weather_api = weather_api
|
||||
doc.mount(app)
|
||||
api.mount(app)
|
||||
view.mount(app)
|
||||
return app
|
||||
|
||||
Reference in New Issue
Block a user