28 lines
681 B
Python
28 lines
681 B
Python
from contextlib import asynccontextmanager
|
|
from fastapi import FastAPI
|
|
|
|
from hub import hub_router
|
|
from hub.db import init_db as hub_init_db
|
|
|
|
from firm import firm_router
|
|
from firm.db import init_db as firm_init_db
|
|
|
|
|
|
if __name__ == '__main__':
|
|
import uvicorn
|
|
uvicorn.run("main:app", host='0.0.0.0', port=8000, reload=True)
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
await hub_init_db()
|
|
await firm_init_db()
|
|
# create_db_and_tables()
|
|
# create_admin_user()
|
|
yield
|
|
# do something before end
|
|
|
|
app = FastAPI(root_path="/api/v1", lifespan=lifespan)
|
|
app.include_router(hub_router, prefix="/hub")
|
|
app.include_router(firm_router, prefix="/firm")
|