yuting111222's picture
Merge Hugging Face Space with local changes
abf050e
raw
history blame contribute delete
987 Bytes
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.routers import ai_router, meal_router
from app.database import engine, Base
# 創建資料庫表
Base.metadata.create_all(bind=engine)
app = FastAPI(title="Health Assistant API")
# 配置 CORS
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:5173"], # React 開發伺服器的位址
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# 註冊路由
app.include_router(ai_router.router)
app.include_router(meal_router.router)
@app.get("/")
async def root():
return {"message": "Health Assistant API is running"}
@app.get("/health")
async def health_check():
"""健康檢查端點"""
return {
"status": "healthy",
"routers": ["ai_router", "meal_router"],
"endpoints": [
"/ai/analyze-food-image/",
"/ai/analyze-food-image-with-weight/",
"/ai/health"
]
}