from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from app.config import API_TITLE, API_VERSION # Create FastAPI application app = FastAPI(title=API_TITLE, version=API_VERSION) # Configure CORS app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) @app.get("/") def root(): return {"message": "欢迎使用笑话大全 API"} @app.get("/health") def health_check(): return {"status": "healthy"}