2022-10-04 05:01:38 +00:00
|
|
|
from fastapi import Depends, FastAPI
|
2022-09-11 10:34:18 +00:00
|
|
|
|
|
|
|
from core.events import close_orm, init_orm
|
2022-09-13 05:31:15 +00:00
|
|
|
from core.exceptions import exception_handlers
|
2022-09-12 07:11:12 +00:00
|
|
|
from core.middleware import middlewares
|
2022-10-04 05:01:38 +00:00
|
|
|
from core.security import check_permissions
|
2022-10-04 04:40:11 +00:00
|
|
|
from core.utils import load_routers
|
2022-09-11 10:34:18 +00:00
|
|
|
|
|
|
|
app = FastAPI(
|
2022-09-12 07:11:12 +00:00
|
|
|
on_startup=[init_orm],
|
2022-09-11 10:34:18 +00:00
|
|
|
on_shutdown=[close_orm],
|
2022-09-12 07:11:12 +00:00
|
|
|
middleware=middlewares,
|
2022-09-13 05:31:15 +00:00
|
|
|
exception_handlers=exception_handlers,
|
2022-09-11 10:34:18 +00:00
|
|
|
)
|
|
|
|
|
2022-10-04 10:19:26 +00:00
|
|
|
load_routers(app, "router", no_depends="auth", depends=[Depends(check_permissions)])
|
2022-09-16 17:11:21 +00:00
|
|
|
|
2022-09-12 07:11:12 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
import uvicorn
|
2022-09-11 10:34:18 +00:00
|
|
|
|
2023-05-31 12:34:10 +00:00
|
|
|
uvicorn.run("main:app", reload=True)
|