浏览代码

Merge branch 'main' of https://git.yunzhixue.cn/linh/question-repeat

swjian 3 周之前
父节点
当前提交
28d4e76054
共有 2 个文件被更改,包括 6 次插入0 次删除
  1. 5 0
      app.py
  2. 1 0
      requirements.txt

+ 5 - 0
app.py

@@ -1,7 +1,9 @@
 from flask import Flask, request, jsonify
+from flask_cors import CORS
 from duplicate_checker import QuestionDuplicateChecker
 
 app = Flask(__name__)
+CORS(app) # 启用跨域支持
 # 初始化查重器(全局单例,避免重复加载索引)
 checker = QuestionDuplicateChecker()
 
@@ -12,6 +14,7 @@ def check_duplicate():
     参数: stem, options, answer, solution
     """
     data = request.get_json()
+    print(f"📥 收到查重请求 (内容比对): {data}")
     if not data:
         return jsonify({"code": -1, "message": "Missing content"}), 400
 
@@ -50,6 +53,7 @@ def check_duplicate():
 @app.route('/api/sync', methods=['POST'])
 def sync_index():
     """手动触发全量同步接口"""
+    print("🔄 收到同步索引请求")
     try:
         checker.sync_all_from_db()
         return jsonify({"code": 0, "result": "Sync completed"})
@@ -63,6 +67,7 @@ def confirm_repeat():
     参数: questionId, isRepeat (0: 无相似, 1: 有重复)
     """
     data = request.get_json()
+    print(f"📥 收到确认结果请求: {data}")
     if not data:
         return jsonify({"code": -1, "message": "Missing JSON body"}), 400
     

+ 1 - 0
requirements.txt

@@ -1,4 +1,5 @@
 flask
+flask-cors
 openai
 numpy
 faiss-cpu