-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
32 lines (23 loc) · 783 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
from flask import Flask, request
from auto_answer import get_data
from auto_answer import get_answer
app = Flask(__name__)
@app.route('/')
def hello_world():
return '欢迎试用人工智障问答系统'
@app.route('/recommend_answers')
def recommend_answers():
question = request.args.get('question')
print(question)
answer_dict = get_answer(question.strip())
result = {}
for index, value in answer_dict:
if index < 3:
print(answer_dict[index])
q = get_data()["question"][answer_dict[index][0]]
s = get_data()["answer"][answer_dict[index][0]]
result[q] = s
return result
if __name__ == '__main__':
app.config['JSON_AS_ASCII'] = False
app.run(debug=True, host='0.0.0.0', port=8080)