utils.py 文件源码

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

项目:django-eventstream 作者: fanout 项目源码 文件源码
def sse_encode_event(event_type, data, event_id=None, escape=False):
    data_str = json.dumps(data, cls=DjangoJSONEncoder)
    if escape:
        event_type = build_id_escape(event_type)
        data_str = build_id_escape(data_str)
    out = 'event: %s\n' % event_type
    if event_id:
        out += 'id: %s\n' % event_id
    out += 'data: %s\n\n' % data_str
    return out
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号