28 lines
689 B
Python
28 lines
689 B
Python
from fastapi import FastAPI
|
|
from fastapi.responses import RedirectResponse
|
|
from fastapi.staticfiles import StaticFiles
|
|
|
|
from gallery.sketch.bundle import ApiBundle
|
|
from gallery.util import root_path
|
|
|
|
from .route import api, view
|
|
|
|
|
|
def build_app(api_bundle: ApiBundle) -> FastAPI:
|
|
app = FastAPI(
|
|
title="Gallery",
|
|
docs_url=None,
|
|
redoc_url=None,
|
|
)
|
|
app.state.api = api_bundle
|
|
app.mount("/static", StaticFiles(directory=root_path / "static/dist"))
|
|
api.app.state.api = api_bundle
|
|
app.mount("/api", api.app)
|
|
app.include_router(view.router)
|
|
|
|
@app.get("/docs")
|
|
def get_docs():
|
|
return RedirectResponse("/api/docs")
|
|
|
|
return app
|