28 lines
708 B
Python
28 lines
708 B
Python
import locale as _locale
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.staticfiles import StaticFiles
|
|
|
|
from gallery.sketch.bundle import ApiBundle
|
|
from gallery.util import root_path
|
|
|
|
from .route import api, doc
|
|
from .route.view import router as view_router
|
|
|
|
DEFAULT_LOCALE = "ru_RU.UTF-8"
|
|
|
|
|
|
def build_app(api_bundle: ApiBundle, *, locale: str = DEFAULT_LOCALE) -> FastAPI:
|
|
_locale.setlocale(_locale.LC_TIME, locale)
|
|
app = FastAPI(
|
|
title="Gallery",
|
|
docs_url=None,
|
|
redoc_url=None,
|
|
)
|
|
app.state.api = api_bundle
|
|
app.mount("/static", StaticFiles(directory=root_path / "static/dist"))
|
|
doc.mount(app)
|
|
api.mount(app)
|
|
app.include_router(view_router)
|
|
return app
|