Taken from this answer, you can zip your images and send them:
This is all the code you need using the Zip files. It will
return a zip file with all of your files.
In my program everything I want to zip is in an output folder so i
just use os.walk and put it in the zip file with write. Before
returning the file you need to close it, if you don't close
it will return an empty file.
import zipfile
import os
from flask import send_file
@app.route('/download_all')
def download_all():
zipf = zipfile.ZipFile('Name.zip','w', zipfile.ZIP_DEFLATED)
for root,dirs, files in os.walk('output/'):
for file in files:
zipf.write('output/'+file)
zipf.close()
return send_file('Name.zip',
mimetype = 'zip',
attachment_filename= 'Name.zip',
as_attachment = True)
In the html I simply call the route:
<a href="{{url_for( 'download_all')}}"> DOWNLOAD ALL </a>
I hope this helped somebody. :)