简体   繁体   English

怎样为基于python的龙卷风Web服务器提供一个zip文件?

[英]How can serve a (python based) tornado webserver a zip file?

I'm using a python based tornado webserver. 我正在使用基于python的龙卷风网络服务器。 I would like to download a zip file at the client side from the webserver. 我想从Web服务器在客户端下载一个zip文件。

I can serve a simple .csv file but not a .zip file. 我可以提供一个简单的.csv文件,但不能提供.zip文件。


This is how I make downloadable a .csv file: 这就是我使可下载.csv文件的方式:

输入图像描述![在此处输入图像描述

... ...

在此处输入图片说明


This is how I tried to serve a .zip file: 这是我尝试提供.zip文件的方式: 在此处输入图片说明

When I try to download the file, I get this error message: 当我尝试下载文件时,出现以下错误消息:

在此处输入图片说明

In python 3, binary files like zip files must be opened in binary mode. 在python 3中,二进制文件(如zip文件)必须以二进制模式打开。 Use "rb" instead of "r" as the second argument to open() . 使用“ rb”代替“ r”作为open()的第二个参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM