app.py 656 B

1234567891011121314151617181920212223242526272829303132333435
  1. from flask import Flask,render_template, request, jsonify
  2. app = Flask(__name__)
  3. # 后台接口
  4. @app.route("/")
  5. def home():
  6. return render_template('index.html')
  7. @app.route('/msg', methods=['POST'])
  8. def inputMsg():
  9. # 从请求中获取JSON数据
  10. data = request.get_json()
  11. # 检查是否接收到数据
  12. if not data:
  13. return jsonify({"error": "No data received"}), 400
  14. # 打印接收到的消息
  15. print(data['msg'])
  16. msg=data['msg']
  17. # 调用大模型解析
  18. #
  19. print(msg)
  20. # 返回响应
  21. return jsonify({"message": "数据已接收", "received": data})
  22. if __name__ == '__main__':
  23. app.run()