flask_sse.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:flask-sse 作者: singingwolfboy 项目源码 文件源码
def stream(self):
        """
        A view function that streams server-sent events. Ignores any
        :mailheader:`Last-Event-ID` headers in the HTTP request.
        Use a "channel" query parameter to stream events from a different
        channel than the default channel (which is "sse").
        """
        channel = request.args.get('channel') or 'sse'

        @stream_with_context
        def generator():
            for message in self.messages(channel=channel):
                yield str(message)

        return current_app.response_class(
            generator(),
            mimetype='text/event-stream',
        )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号