我正在开发一个模拟面试环节的webapp。会话结束后,聊天机器人应该显示消息。我的前端是js,后端是python烧瓶。聊天机器人应该在没有用户响应的情况下发送消息,它应该启动。我的问题是后端函数工作正常,但是它在控制台中打印回复,而不是聊天机器人接口。
@app.route("/post_interview", methods = ['POST'])
def chat_reply():
print("in_post")
response = get_response("results")
print(response)
message ={"answer":response}
return jsonify(message)知道我怎么能解决这个问题吗?
发布于 2022-05-25 14:53:39
打印功能只适用于控制台,这是正常的,你没有看到它在屏幕上。若要将html呈现到网页,必须使用render_template()。
下面是一个示例:
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def index(): # renders index.html that is inside templates folder
return render_template('index.html')
if __name__ == '__main__':
app.run()现在,当您访问网站的url时,您将在index.html中看到html。
https://stackoverflow.com/questions/72379800
复制相似问题