Browse Source

we can download a zip folder hehehe

master
zeroth 4 years ago
parent
commit
9847e85095
  1. 35
      library.py

35
library.py

@ -99,7 +99,7 @@ def test():
print("test")
clicked=None
bundle = "bundle.zip"
zipObj = ZipFile(bundle, 'w')
# zipObj = ZipFile(bundle, 'w')
if request.method == "POST":
# clicked=request.form['data']
@ -108,23 +108,20 @@ def test():
print(listofselecteddocs)
print("hola")
# create a ZipFile object
with ZipFile(bundle, 'w') as zipObj2:
# Add multiple files to the zip
zipObj.write('static/files/'+listofselecteddocs[0])
zipObj.write('static/files/'+listofselecteddocs[1])
zipObj.write('static/default-files/hello.txt')
# close the Zip File
# return render_template('test.html')
# return send_file(bundle, mimetype='application/zip', as_attachment=True, attachment_filename=bundle)
# TEST
# print("sending file...")
# result = send_file(bundle, as_attachment=True)
# print("file sent, deleting...")
# os.remove(bundle)
# return result
zipObj.close()
return send_file(bundle, mimetype='application/zip', attachment_filename="hello.zip", as_attachment=True)
readmeabsname = 'static/default-files/hello.txt'
readmearcname = "hello.txt"
zipObj2.write(readmeabsname,readmearcname)
for doc in listofselecteddocs:
absname = 'static/files/'+doc
print(doc)
arcname = os.path.basename(doc)
zipObj2.write(absname, arcname)
return send_file(bundle, mimetype='application/zip', attachment_filename="bundle.zip", as_attachment=True)

Loading…
Cancel
Save