first commit
This commit is contained in:
26
app/main.py
Normal file
26
app/main.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from fastapi import FastAPI
|
||||
from contextlib import asynccontextmanager
|
||||
from typing import AsyncGenerator
|
||||
|
||||
from app.core.config import settings
|
||||
from app.db.session import engine
|
||||
from app.db.base import SQLModel
|
||||
from app.api.routers import auth, users
|
||||
|
||||
|
||||
def create_app() -> FastAPI:
|
||||
app = FastAPI(title="FastAPI Account System")
|
||||
app.include_router(auth.router, prefix="/auth", tags=["auth"])
|
||||
app.include_router(users.router, prefix="/users", tags=["users"])
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app) -> AsyncGenerator[None, None]:
|
||||
# For quick local runs create tables automatically. In production use Alembic migrations.
|
||||
SQLModel.metadata.create_all(engine)
|
||||
yield
|
||||
|
||||
app.router.lifespan_context = lifespan
|
||||
return app
|
||||
|
||||
|
||||
app = create_app()
|
||||
Reference in New Issue
Block a user