
- Set up project structure with FastAPI and SQLite - Created Todo model with SQLAlchemy ORM - Added CRUD operations for todos - Implemented API endpoints for Todo operations - Added health check endpoint - Added Alembic for database migrations - Updated README with documentation generated with BackendIM... (backend.im)
31 lines
780 B
Python
31 lines
780 B
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.api import todos, health
|
|
from app.database.base import engine, Base
|
|
|
|
# Create tables
|
|
Base.metadata.create_all(bind=engine)
|
|
|
|
app = FastAPI(
|
|
title="Todo Application API",
|
|
description="A simple Todo application API built with FastAPI and SQLite",
|
|
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(todos.router, prefix="/api", tags=["todos"])
|
|
app.include_router(health.router, tags=["health"])
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True) |