
- Set up project structure with FastAPI and SQLite - Implement Todo model and CRUD operations - Add health endpoint for application monitoring - Configure Alembic for database migrations - Add comprehensive documentation generated with BackendIM... (backend.im)
31 lines
743 B
Python
31 lines
743 B
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
import uvicorn
|
|
|
|
from app.routers import todo, health
|
|
from app.database import Base, engine
|
|
|
|
# Create tables
|
|
Base.metadata.create_all(bind=engine)
|
|
|
|
app = FastAPI(
|
|
title="Simple Todo App",
|
|
description="A simple Todo application API",
|
|
version="0.1.0"
|
|
)
|
|
|
|
# Add CORS middleware
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Include routers
|
|
app.include_router(todo.router, prefix="/api/todos", tags=["todos"])
|
|
app.include_router(health.router, tags=["health"])
|
|
|
|
if __name__ == "__main__":
|
|
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True) |