File Downloading Callback Works Locally But Not Online

In my script, I have a callback connected to two dropdowns, a button, and a dcc.Download object. Everything works perfectly locally. I can choose and download all four of the different file options (xlsx, csv, parquet, and a px.scatter_geo figure html).

But when I run the script online, I am only able to successfully download the xlsx and csv files, but not the parquet or px.scatter_geo figure html. When I click the button, I can see the browser loading like it does for the other two files, but then nothing happens. There are no error messages, and the application does not fail or crash at any point.

Here is a simplified version of the callback:

    Output("download_file", "data"),
     Input("download_button", "n_clicks"),
def downloader(s_drop, download_type_drop, n_clicks):
    df_f = df_o1.copy()

    if s_drop: 
        df_d = df_f[df_f['s'] == s_drop]
        df_d = pandas.DataFrame(dict(A='none selected'), index=[0])
    if n_clicks == 0 :
        raise PreventUpdate
        if download_type_drop == 'csv': return dcc.send_data_frame(df_d.to_csv, str(s_drop) + "_data.csv")
        if download_type_drop == 'xlsx': return dcc.send_data_frame(df_d.to_excel, str(s_drop) + "_data.xlsx")
        if download_type_drop == 'parquet': return dcc.send_data_frame(df_d.to_parquet, str(s_drop) + "_data.parquet")
        if download_type_drop == 'geo_scatter': 
            if not s_drop: 
                raise PreventUpdate
                fig = px.scatter_geo(df_d, lat = 'latitudeofdtc', lon = 'longitudeofdtc')
                with open(cwd + r'\states_geojson.json') as i:
                    states_geojson = json.load(i)
                fig = fig.add_trace(
                        lat=[v for sub in [np.array(f["geometry"]["coordinates"])[:, 1].tolist() + [None]
                                for f in states_geojson["features"]] for v in sub],
                        lon=[v for sub in [np.array(f["geometry"]["coordinates"])[:, 0].tolist() + [None]
                                for f in states_geojson["features"]] for v in sub],
                return dict(content=fig.to_html(), filename=str(s_drop) + "_geo_scatter.html")
        if not download_type_drop: raise PreventUpdate

I’m not sure what the problem could be, since it works perfect locally, and since the xlsx and csv files can be downloaded online without issue. Any help would be appreciated.


Hello @mromanel,

My guess is that you dont have anything on the server you are using that can handle sending those file types.

For the html, I’ve not tried to download a page from an external site, it may be getting blocked by your network?

You may be right, although I find it strange that csv and xlsx files can get through, but not parquet or html. It’s a work computer/cloud, with security features I can’t control, so I’m not sure I’ll be able to solve this one, might have to build a workaround.

But thanks for the response