Automated Action 852e0a32b1 Create simple FastAPI application with SQLite and Alembic
- Set up project structure
- Create FastAPI app with health endpoint
- Implement SQLAlchemy with SQLite database
- Set up Alembic for database migrations
- Create CRUD operations for items
- Add comprehensive documentation
2025-05-20 14:20:21 +00:00

37 lines
980 B
Python

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import uvicorn
from app.api.endpoints import health, items
from app.core.config import settings
from app.db.session import engine
from app.models import models
# Create database tables
models.Base.metadata.create_all(bind=engine)
app = FastAPI(
title=settings.PROJECT_NAME,
description=settings.PROJECT_DESCRIPTION,
version=settings.PROJECT_VERSION,
openapi_url=f"{settings.API_V1_STR}/openapi.json",
docs_url="/docs",
redoc_url="/redoc",
)
# Set up CORS middleware
app.add_middleware(
CORSMiddleware,
allow_origins=settings.ALLOWED_ORIGINS,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include routers
app.include_router(health.router, tags=["health"])
app.include_router(items.router, prefix=settings.API_V1_STR, tags=["items"])
if __name__ == "__main__":
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)