-
Notifications
You must be signed in to change notification settings - Fork 71
/
app.py
33 lines (24 loc) · 846 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# encoding=utf-8
from models.chatbot_model import ChatbotModel
from utils.app_init import before_init
from utils.helpers import load_all_scene_configs
from flask import Flask, request, jsonify, send_file
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
# 实例化ChatbotModel
chatbot_model = ChatbotModel(load_all_scene_configs())
@app.route('/multi_question', methods=['POST'])
def api_multi_question():
data = request.json
question = data.get('question')
if not question:
return jsonify({"error": "No question provided"}), 400
response = chatbot_model.process_multi_question(question)
return jsonify({"answer": response})
@app.route('/', methods=['GET'])
def index():
return send_file('./demo/user_input.html')
if __name__ == '__main__':
before_init()
app.run(port=5000, debug=True)