[英]cannot return response to browser flask
I have a web service which should be stay listening for a new message for real-time chat, the problem that I cannot return it's response nor a simple text because this part of code:我有一个 web 服务,它应该保持监听实时聊天的新消息,问题是我无法返回它的响应或简单的文本,因为这部分代码:
# Print every message the current user would receive
# This is a blocking call that will run forever
(client.call_on_each_message(debug))
stay listening forever so I implement an actual function to return the responses but my code ends with printing test without passing to return the message, this line of code:永远保持倾听,所以我实现了一个实际的 function 来返回响应,但我的代码以打印测试结束,没有通过返回消息,这行代码:
return jsonify((str(msg))), 200
what shall I do to return the response to the browser我该怎么做才能将响应返回给浏览器
@app.route('/listenrealtime', methods=['GET'])
def listenrealtime():
def debug(msg):
msg: lambda msg: (str(msg))
print('test')
print(msg)
return jsonify((str(msg))), 200
# Pass the path to your zuliprc file here.
client = zulip.Client(config_file="~/zuliprc")
# Print every message the current user would receive
# This is a blocking call that will run forever
(client.call_on_each_message(debug))
# Print every event relevant to the user
# This is a blocking call that will run forever
return "Some text"
It fails to return because of a misplaced parenthesis:它由于错位的括号而无法返回:
return jsonify(((str(msg)), 200)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.