Automated Action e1ed70e281 Create FastAPI Todo API application
- Set up project structure and requirements
- Create database models and connection
- Set up Alembic for migrations
- Implement CRUD operations for todos
- Build RESTful API endpoints
- Update README with project documentation

generated with BackendIM... (backend.im)
2025-05-11 19:49:50 +00:00

33 lines
740 B
Python

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import uvicorn
from api.routes import todos
from db.database import Base, engine
# Create tables
Base.metadata.create_all(bind=engine)
app = FastAPI(
title="Todo API",
description="A simple Todo API built with FastAPI and SQLite",
version="1.0.0"
)
# Configure CORS
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include routers
app.include_router(todos.router, prefix="/api")
@app.get("/")
def root():
return {"message": "Welcome to Todo API"}
if __name__ == "__main__":
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)