Automated Action ecb15eb903 Build complete task management tool with FastAPI
- Implemented full CRUD operations for tasks
- Added SQLite database with SQLAlchemy ORM
- Set up Alembic migrations for database schema
- Created health check and base URL endpoints
- Added CORS middleware for cross-origin requests
- Included comprehensive API documentation
- Updated README with complete project information
2025-06-20 03:21:46 +00:00

55 lines
1.3 KiB
Python

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)
}