代码拉取完成,页面将自动刷新
from flask import Flask, make_response, request
from chatbot_graph import ChatBotGraph
handler = ChatBotGraph()
app = Flask(__name__)
@app.after_request
def af_request(*resp_raw):
resp = make_response(*resp_raw)
resp.headers['Access-Control-Allow-Origin'] = '*'
resp.headers['Access-Control-Allow-Methods'] = 'GET,POST'
resp.headers['Access-Control-Allow-Headers'] = 'x-requested-with,content-type'
return resp
@app.route('/', methods=['GET', 'POST'])
def a():
print(request.json)
data = request.json
if not data:
return ''
text = data['text']['content'].strip()
user = data['senderNick']
user_id = user
print(text)
answer = handler.chat_main(text, user_id)
resp_text = {
"at": {
"atUserIds": [
user_id
],
"isAtAll": False
},
"msgtype": "markdown",
"markdown": {
"title": "快来问我啊",
"text": answer[0],
},
}
print(resp_text)
return resp_text
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5005, debug=False)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。