Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Make sure that clicking on a download button does not reload the entire appΒ #4382

@vhoulbreque

Description

@vhoulbreque

Problem

The Streamlit app reloads entirely when clicking on a st.download_button. In my case, I think it should not: download buttons are different from buttons and should not trigger a reload of the app. They should only trigger a download.

I perfectly understand that a click on a button does reload the app (to recompute) but downloads don't change the view, downloads don't trigger computations etc.

I also know about the cache, but it is not always a proper solution: what about apps with a st.forms? The user should not have to click on yet another button to generate the same view that has not changed one bit. The same goes if several files can be downloaded: it can be very cumbersome to do such a simple task.

Solution

Several options:

  1. Stop reloading the app for a st.download_button
  2. Add a parameter to trigger (or not) a reload of the page when clicking on a st.download_button.

Additional context

See this discourse: https://discuss.streamlit.io/t/stop-page-from-reloading-after-using-downloader/18744

And this code to reproduce the problem exposed above:

import streamlit as st

def long_computation():
    import time
    time.sleep(10)

st.header("TEST DOWNLOAD BUTTON")

with st.spinner("Running a long computation.."):
    long_computation()

st.download_button("Download", "a")

Community voting on feature requests enables the Streamlit team to understand which features are most important to our users.

If you'd like the Streamlit team to prioritize this feature request, please use the πŸ‘ (thumbs up emoji) reaction in response to the initial post.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature:st.download_buttonRelated to the `st.download_button` widgettype:enhancementRequests for feature enhancements or new features

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions