我启用了调试,但它没有显示任何内容。我看到的只是“500 内部服务器错误。我在这个脚本中做错了什么?
Python
import zipfile
from zipfile import ZipFile
import cStringIO as StringIO
from django.http import HttpResponse
from django.core.servers.basehttp import FileWrapper
def zipit (request):
files = ['/home/dbs/public_html/download/codex/video.html', '/home/dbs/public_html/download/audio/audio.html']
buffer= StringIO.StringIO()
z= zipfile.ZipFile( buffer, "w" )
[z.write(f) for f in files]
z.close()
response = HttpResponse(FileWrapper(z), content_type='application/zip')
response['Content-Disposition'] = 'attachment; filename=z.zip'
return HttpResponse(response, mimetype="application/x-zip-compressed")