Spaces:
No application file
No application file
| from contextlib import asynccontextmanager | |
| from fastapi import FastAPI | |
| from routes import tasks | |
| from routes import auth | |
| from sqlmodel import SQLModel | |
| from config.database import engine | |
| from models.user import User | |
| from models.task import Task | |
| async def lifespan(app: FastAPI): | |
| # Create tables on startup | |
| async with engine.begin() as conn: | |
| await conn.run_sync(SQLModel.metadata.create_all) | |
| yield | |
| app = FastAPI(title="Todo Backend API", version="1.0.0", lifespan=lifespan) | |
| # Include the auth router | |
| app.include_router(auth.router, prefix="/api", tags=["auth"]) | |
| # Include the tasks router | |
| app.include_router(tasks.router, prefix="/api/v1", tags=["tasks"]) | |
| def read_root(): | |
| return {"message": "Welcome to the Todo Backend API"} |