Automated Action 02cc12cad8 Add FastAPI REST API service with CRUD operations
- Created main FastAPI application with CORS middleware
- Added SQLite database configuration with SQLAlchemy
- Implemented Items model with create, read, update, delete operations
- Set up Alembic migrations for database schema management
- Added comprehensive API endpoints at /api/v1/items/
- Included health check endpoint at /health
- Added proper Pydantic schemas for request/response validation
- Updated README with complete documentation and usage instructions
- Configured Ruff for code linting and formatting
2025-06-20 10:55:10 +00:00

43 lines
929 B
Python

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import uvicorn
from app.api.items import router as items_router
from app.db.base import engine, Base
Base.metadata.create_all(bind=engine)
app = FastAPI(
title="REST API Service",
description="A FastAPI REST API service",
version="1.0.0",
openapi_url="/openapi.json",
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(items_router, prefix="/api/v1", tags=["items"])
@app.get("/")
async def root():
return {
"title": "REST API Service",
"documentation": "/docs",
"health_check": "/health",
}
@app.get("/health")
async def health_check():
return {"status": "healthy", "service": "REST API Service"}
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000)