|
@@ -13,7 +13,19 @@ from flask import Flask
|
|
|
|
|
|
|
|
# 初始化 Flask 应用
|
|
# 初始化 Flask 应用
|
|
|
app = Flask(__name__)
|
|
app = Flask(__name__)
|
|
|
-
|
|
|
|
|
|
|
+# 配置 CORS 中间件 - 允许跨域请求
|
|
|
|
|
+app.add_middleware(
|
|
|
|
|
+ CORSMiddleware,
|
|
|
|
|
+ allow_origins=[
|
|
|
|
|
+ "http://localhost:5173", # Vue 开发服务器
|
|
|
|
|
+ "http://127.0.0.1:5173", # Vue 开发服务器(另一个地址)
|
|
|
|
|
+ "http://192.168.124.25:5173", # 局域网 Vue 地址
|
|
|
|
|
+ "*", # 允许所有来源(生产环境建议限制具体域名)
|
|
|
|
|
+ ],
|
|
|
|
|
+ allow_credentials=True,
|
|
|
|
|
+ allow_methods=["*"], # 允许所有 HTTP 方法 (GET, POST, PUT, DELETE 等)
|
|
|
|
|
+ allow_headers=["*"], # 允许所有请求头
|
|
|
|
|
+)
|
|
|
# 批量注册所有路由
|
|
# 批量注册所有路由
|
|
|
for router in all_routers:
|
|
for router in all_routers:
|
|
|
app.include_router(router)
|
|
app.include_router(router)
|
|
@@ -30,7 +42,6 @@ def test_env():
|
|
|
async def health_check():
|
|
async def health_check():
|
|
|
return {"status": "healthy", "service": "multi_domain_intent_recognition"}
|
|
return {"status": "healthy", "service": "multi_domain_intent_recognition"}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
# ========== 缓存管理 API ==========
|
|
# ========== 缓存管理 API ==========
|
|
|
@app.post("/api/v1/cache/clear")
|
|
@app.post("/api/v1/cache/clear")
|
|
|
async def clear_all_caches():
|
|
async def clear_all_caches():
|
|
@@ -76,6 +87,7 @@ async def clear_all_caches():
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
"status": "success",
|
|
"status": "success",
|
|
|
|
|
+ "code": 200,
|
|
|
"message": "所有缓存已清除",
|
|
"message": "所有缓存已清除",
|
|
|
"timestamp": time.time()
|
|
"timestamp": time.time()
|
|
|
}
|
|
}
|