
- Create FastAPI application with CORS support - Implement Task model with SQLAlchemy - Set up database session and migrations with Alembic - Add CRUD endpoints for task management - Include health check and API documentation endpoints - Configure Ruff for code formatting and linting
34 lines
774 B
Python
34 lines
774 B
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from app.api import tasks_router
|
|
from app.db import Base, engine
|
|
|
|
Base.metadata.create_all(bind=engine)
|
|
|
|
app = FastAPI(
|
|
title="Task Manager API",
|
|
description="A simple task manager API built with FastAPI",
|
|
version="1.0.0",
|
|
openapi_url="/openapi.json",
|
|
)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(tasks_router, prefix="/api/v1")
|
|
|
|
|
|
@app.get("/")
|
|
def read_root():
|
|
return {"title": "Task Manager API", "documentation": "/docs", "health": "/health"}
|
|
|
|
|
|
@app.get("/health")
|
|
def health_check():
|
|
return {"status": "healthy", "service": "Task Manager API"}
|