How to download multiple files with flask?

what has been implemented:

write a website in flask, enter data in the form, click submit, and download a generated word. (using flask-wtf and send_file)

but what I want to do now is to click submit and generate two different word for download.

attach some code (submit the form, download the first generated word):

def index():
    name = None
    form = NameForm()
    if form.validate_on_submit():
        document = Document()
        f = io.BytesIO()
        document.save(f)
        length = f.tell()
        f.seek(0)
        filename = quote(name+".doc")
        rv = send_file(f, as_attachment=True,attachment_filename=filename)
        rv.headers["Content-Disposition"] += "; filename*=utf-8""{}".format(filename)
        return rv

Mar.30,2021

each request should return only one file, so it is theoretically impossible to download multiple files directly through a single request.
solution:
multiple files are generated in memory, and then multiple files are packaged into compressed files to provide downloads of compressed files.
https://stackoverflow.com/que.

Menu