match_question()方法对应的http请求为:http://your_ip:your_port/matchQa?question=被抢劫了,怎么办
from app import api
from flask import request, jsonify
from app.match_qa_model import MatchQuestionAnswer
@api.route('matchQa', methods=['GET', 'POST'])
def match_question():
try:
data = request.get_json()
question = data.get("question")
except:
question = request.args.get("question", "")
model = MatchQuestionAnswer()
data = model.run(question)
return jsonify(data)
predict()方法对应的http请求为:http://your_ip:your_port/predict?sentence=我想咨询离婚的事情
@app.route('/predict', methods=['POST'])
def predict():
try:
sentence = request.args.get("sentence")
app.logger.error('this is not a error')
print(sentence)
return utils_predict.predict(sentence,app)
except Exception as e:
b = bytes(str(e), encoding='utf-8')
app.logger.error('this is a error')
app.logger.error("Error {0}".format(str(b, encoding='utf-8')))
return "Error {0}".format(str(b, encoding='utf-8'))
网友评论