from fastapi import FastAPI, Depends from fastapi.middleware.cors import CORSMiddleware from sqlalchemy.orm import Session from sqlalchemy import text from app.db.session import get_db, engine from app.db.base import Base from app.routers import tasks app = FastAPI( title="Task Management Tool", description="A FastAPI-based task management system", version="1.0.0", openapi_url="/openapi.json" ) app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) Base.metadata.create_all(bind=engine) app.include_router(tasks.router, prefix="/tasks", tags=["tasks"]) @app.get("/") async def root(): return { "title": "Task Management Tool", "description": "A FastAPI-based task management system", "documentation": "/docs", "health_check": "/health" } @app.get("/health") async def health_check(db: Session = Depends(get_db)): try: db.execute(text("SELECT 1")) return { "status": "healthy", "database": "connected", "service": "task-management-tool" } except Exception as e: return { "status": "unhealthy", "database": "disconnected", "service": "task-management-tool", "error": str(e) }