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