
- Create complete task management system with CRUD operations - Add Task model with status, priority, timestamps - Set up SQLite database with SQLAlchemy and Alembic migrations - Implement RESTful API endpoints for task operations - Configure CORS middleware and API documentation - Add health check endpoint and root information response - Include proper project structure and comprehensive README
38 lines
890 B
Python
38 lines
890 B
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from app.db.session import create_tables
|
|
from app.routers import tasks
|
|
|
|
app = FastAPI(
|
|
title="Task Management API",
|
|
description="A simple task management tool built with FastAPI",
|
|
version="1.0.0",
|
|
openapi_url="/openapi.json"
|
|
)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
create_tables()
|
|
|
|
app.include_router(tasks.router, prefix="/tasks", tags=["tasks"])
|
|
|
|
|
|
@app.get("/")
|
|
def root():
|
|
return {
|
|
"title": "Task Management API",
|
|
"description": "A simple task management tool built with FastAPI",
|
|
"documentation": "/docs",
|
|
"health_check": "/health"
|
|
}
|
|
|
|
|
|
@app.get("/health")
|
|
def health_check():
|
|
return {"status": "healthy", "service": "Task Management API"} |