How to zip an html file from a stream/rendered dictionary?

Solution
from flask import render_template, send_file
from io import BytesIO
from zipfile import ZipFile

# ...

@app.route('/download')
def download():
    output = { 'name': 'Unknown' }
    result_html = render_template('result.html', **output)

    stream = BytesIO()
    with ZipFile(stream, 'w') as zf:
        zf.writestr('result.html', result_html)
        # ...
    stream.seek(0)

    return send_file(stream, as_attachment=True, attachment_filename='archive.zip')