[英]cannot return response to browser flask
我有一個 web 服務,它應該保持監聽實時聊天的新消息,問題是我無法返回它的響應或簡單的文本,因為這部分代碼:
# Print every message the current user would receive
# This is a blocking call that will run forever
(client.call_on_each_message(debug))
永遠保持傾聽,所以我實現了一個實際的 function 來返回響應,但我的代碼以打印測試結束,沒有通過返回消息,這行代碼:
return jsonify((str(msg))), 200
我該怎么做才能將響應返回給瀏覽器
@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"
它由於錯位的括號而無法返回:
return jsonify(((str(msg)), 200)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.