我正在寻找一种方法将zipfile发送到客户端,该方法是从请求响应生成的.在此示例中,我将一个
JSON字符串发送到url,该url返回已转换的JSON字符串的zip文件.
@app.route('/sendZip', methods=['POST'])
def sendZip():
content = '{"type": "Point", "coordinates": [-105.01621, 39.57422]}'
data = {'json' : content}
r = requests.post('http://ogre.adc4gis.com/convertJson', data = data)
if r.status_code == 200:
zipDoc = zipfile.ZipFile(io.BytesIO(r.content))
return Response(zipDoc,
mimetype='application/zip',
headers={'Content-Disposition':'attachment;filename=zones.zip'})
但是我的zip文件是空的,而烧瓶返回的错误是
Debugging middleware caught exception in streamed response at a point where response
headers were already sent