繁体   English   中英

无法将响应返回给浏览器 flask

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM