def stream_timelapse(path):
    parts = path.split('.')[0].split('_')
    count = int(parts[2])
    filename = parts[0] + '_{0:03d}_{1:03d}.jpg'
    for i in range(count):
        frame = open(filename.format(i, count), 'rb').read()
        yield b'--frame\r\nContent-Type: image/jpeg\r\nContent-Length: ' + \
            str(len(frame)).encode() + b'\r\n\r\n' + frame + b'\r\n'
        time.sleep(0.5)
Stream the jpegs in a time lapse as a multipart response.
dataset/ETHPy150Open miguelgrinberg/oreilly-flask-apis-video/camera/camera.py/stream_timelapse