forked from mizhexiaoxiao/vue-fastapi-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
39 lines (31 loc) · 834 Bytes
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from fastapi import FastAPI
from app.core.exceptions import SettingNotFound
from app.core.init_app import (
init_menus,
init_superuser,
make_middlewares,
register_db,
register_exceptions,
register_routers,
)
try:
from app.settings.config import settings
except ImportError:
raise SettingNotFound("Can not import settings")
def create_app() -> FastAPI:
app = FastAPI(
title=settings.APP_TITLE,
description=settings.APP_DESCRIPTION,
version=settings.VERSION,
openapi_url="/openapi.json",
middleware=make_middlewares(),
)
register_db(app)
register_exceptions(app)
register_routers(app, prefix="/api")
return app
app = create_app()
@app.on_event("startup")
async def startup_event():
await init_superuser()
await init_menus()