Automated Action 629ba0ee1c Create REST API with FastAPI and SQLite
- Set up project structure with FastAPI app
- Implement SQLAlchemy models and async database connection
- Create CRUD endpoints for items resource
- Add health endpoint for monitoring
- Configure Alembic for database migrations
- Create comprehensive documentation

generated with BackendIM... (backend.im)
2025-05-15 15:49:28 +00:00

30 lines
753 B
Python

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from pathlib import Path
app = FastAPI(
title="Generic REST API Service",
description="A generic REST API service built with FastAPI and SQLite",
version="0.1.0",
)
# Configure CORS
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Import routers
from app.api.health import router as health_router
from app.api.items import router as items_router
# Include routers
app.include_router(health_router)
app.include_router(items_router, prefix="/api")
if __name__ == "__main__":
import uvicorn
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)