32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
from contextlib import asynccontextmanager
|
|
from fastapi import FastAPI
|
|
|
|
from hub.db import init_db as hub_init_db
|
|
from hub.auth import auth_router, register_router, password_router, verification_router, users_router, \
|
|
google_oauth_router, discord_oauth_router
|
|
from hub.firm.routes import router as firm_router
|
|
|
|
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()
|
|
# create_db_and_tables()
|
|
# create_admin_user()
|
|
yield
|
|
# do something before end
|
|
|
|
app = FastAPI(root_path="/api/v1", lifespan=lifespan)
|
|
|
|
app.include_router(register_router, tags=["Auth"], )
|
|
app.include_router(auth_router, prefix="/auth", tags=["Auth"], )
|
|
app.include_router(google_oauth_router, prefix="/auth/google", tags=["Auth"])
|
|
app.include_router(discord_oauth_router, prefix="/auth/discord", tags=["Auth"])
|
|
app.include_router(verification_router, prefix="/auth/verification", tags=["Auth"], )
|
|
app.include_router(users_router, prefix="/users", tags=["Users"], )
|
|
app.include_router(password_router, prefix="/users", tags=["Users"], )
|
|
app.include_router(firm_router, prefix="/firms", tags=["Firms"], )
|