def eventstream(f):
    def new_func(*args, **kwargs):
        def generate():
            for event in chain(f(*args, **kwargs), (None,)):
                yield 'data: %s\n\n' % json.dumps(event)
        return Response(generate(), mimetype='text/event-stream',
                        direct_passthrough=True)
    return update_wrapper(new_func, f)
dataset/ETHPy150Open lektor/lektor-archive/lektor/admin/utils.py/eventstream/original