streaming_flask.py 416 B

123456789101112131415161718192021222324
  1. # flask
  2. from flask import Response
  3. import zipfly
  4. paths = [
  5. {
  6. 'fs': 'home/user/Videos/jupiter.mp4',
  7. 'n': 'movies/jupiter.mp4',
  8. },
  9. ]
  10. # constructor
  11. zfly = zipfly.ZipFly( paths=paths )
  12. # z is a new generator
  13. z = zfly.generator()
  14. # flask streaming
  15. response = Response(z, mimetype='application/zip',)
  16. response.headers['Content-Disposition'] = 'attachment; filename=file.zip'
  17. return response