Automated Action f1784ca3da Create REST API service with FastAPI and SQLite
- Set up FastAPI application with CORS middleware
- Implement SQLite database with SQLAlchemy ORM
- Create user model and schemas for data validation
- Set up Alembic for database migrations
- Add comprehensive CRUD endpoints for user management
- Include health check and service info endpoints
- Configure automatic API documentation
- Update README with complete project documentation
2025-06-26 01:43:42 +00:00

41 lines
998 B
Python

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import uvicorn
from app.api.users import router as users_router
from app.db.session import create_tables
app = FastAPI(
title="REST API Service",
description="A REST API service built with FastAPI",
version="1.0.0",
openapi_url="/openapi.json"
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(users_router, prefix="/api/v1/users", tags=["users"])
@app.on_event("startup")
async def startup_event():
create_tables()
@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("main:app", host="0.0.0.0", port=8000, reload=True)