Skip to navigation
How to serve a zip file with tornado python 3.4
11.01.16
import zipfile import io if(self.get_argument('zip')): f=io.BytesIO() zf = zipfile.ZipFile(f,'w',zipfile.ZIP_DEFLATED) zf.writestr('foo.csv',contents) zf.close() self.set_header('Content-Type', 'application/zip') self.set_header('Content-Disposition', 'attachment; filename=foo.zip') self.write(f.getvalue())
https://pymotw.com/2/zipfile/
Reply
Anonymous
Information Epoch 1732592042
When you must fail, fail noisily and as soon as possible.
Home
Notebook
Contact us