todoapp-vgv7cg/main.py
Automated Action 2c24afcb6c Create simple FastAPI todo application
- Add project structure with FastAPI, SQLAlchemy, and Alembic
- Implement Todo model with CRUD operations
- Add REST API endpoints for todo management
- Configure SQLite database with migrations
- Include health check and API documentation endpoints
- Add CORS middleware for all origins
- Format code with Ruff
2025-06-18 00:30:05 +00:00

35 lines
762 B
Python

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.api.v1 import api_router
from app.db.base import Base
from app.db.session import engine
Base.metadata.create_all(bind=engine)
app = FastAPI(
title="Simple Todo API",
description="A simple todo application built with FastAPI",
version="1.0.0",
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(api_router, prefix="/api/v1")
@app.get("/")
def read_root():
return {"title": "Simple Todo API", "documentation": "/docs", "health": "/health"}
@app.get("/health")
def health_check():
return {"status": "healthy", "service": "todo-api"}