Solution for downloading a zipped folder/directory?

I’m looking to create a link to be able to download a zipped folder that already exists in the same directory as the dash application. I’ve seen solutions to download raw csv data (Download raw data), but am not quite sure how to change this to be able to download a .zip folder.

Here is the basic framework I’m trying to modify (from link above):

        'Download Zipped Folder',

    dash.dependencies.Output('download-link', 'href'),
    [dash.dependencies.Input('field-dropdown', 'value')])
def update_download_link(filter_value):
    dff = filter_data(filter_value)
    csv_string = dff.to_csv(index=False, encoding='utf-8')
    csv_string = "data:text/csv;charset=utf-8," + urllib.quote(csv_string)
    return csv_string

Thanks in advance!

What does the zip contain? One/many CSV files that you want to use in a dataframe?

The zip contains a variety of different files (.txt, .bedgraph, .bed) for the user to download after performing data analysis with the Dash App.

See Allowing users to download CSV on click for a more general solution for serving larger files and to adapt that example to a zip file.

If you get this to work, please post your solution here too!

I was able to get this to work:

from flask import send_file
app = dash.Dash()

app.layout = html.Div([

        'Download Zip',
        download = "",
        n_clicks = 0

    Output('download-zip', 'href'),
    [Input('download-zip', 'n_clicks')])

def generate_report_url(n_clicks):

	return '/dash/urldownload'


def generate_report_url():

	return send_file('', attachment_filename = '', as_attachment = True)

if __name__ == '__main__':
	app.run_server(debug = True)
three reasons why you should buy plotly pro: support open source, get great support, host your plots and dashboards online