2022-09-11 10:34:18 +00:00
|
|
|
from fastapi import FastAPI
|
|
|
|
|
2022-09-16 17:11:21 +00:00
|
|
|
from controller.ws import ws_app
|
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 15:22:18 +00:00
|
|
|
from core.log import logger
|
2022-09-12 07:11:12 +00:00
|
|
|
from core.middleware import middlewares
|
|
|
|
from router.url import routes
|
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
|
|
|
routes=routes,
|
|
|
|
middleware=middlewares,
|
2022-09-13 05:31:15 +00:00
|
|
|
exception_handlers=exception_handlers,
|
2022-09-11 10:34:18 +00:00
|
|
|
)
|
|
|
|
|
2022-09-16 17:11:21 +00:00
|
|
|
app.mount("/", ws_app)
|
|
|
|
|
2022-09-12 07:11:12 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
import uvicorn
|
2022-09-11 10:34:18 +00:00
|
|
|
|
2022-09-12 07:11:12 +00:00
|
|
|
for i in app.routes:
|
2022-09-13 05:31:15 +00:00
|
|
|
logger.info(f"{i.path}, {i.methods}, {i.__dict__.get('summary')}, {i.endpoint}")
|
2022-09-11 10:34:18 +00:00
|
|
|
|
2022-09-12 07:11:12 +00:00
|
|
|
uvicorn.run("main:app", reload=True)
|