Prevent re-loading when pressing download button

Hello, I’m currently developing and deploying a ML dashboard, but I have some incovenients since in one of my pages where I work with the ML model to get a prediction, also I can download an Excel file with the prediction results, but when I click the download button, the page refreshes and results are gone. How can I prevent that?
Also I noticed that if I make a prediction for a date in my local environment it does return the result, but if I make a prediction for the same date in deployment environment, it returns nothing. I tried with dates greater than 24/11/2023, those gave me problems.
Link to app: Dashboard ShriMP · Streamlit (
Link to repo: NoeliaIntriago/Dashboard-ShriMP (
Streamlit v1.28.2, Python v3.9
Any help will be apreciated

Hey @NoeliaIntriago,

Thanks for sharing this question! We have a new feature (currently in preview) that allows you to turn a function into a Streamlit container that can run independently of the larger app.

For now, you can use the preview .whl file to use this feature (and please share any feedback/requests in this thread), and in the future, it will be included as a regular part of the library.

Hi @Caroline , @NoeliaIntriago . Here is the sample python code snippet work for if the user want click the download button for for downloading the Excel sheet even if the main submit button is clicked.

if st.session_state.get('button') != True:
   st.session_state['button'] = bt1
if st.session_state['button'] == True:
    if st.button('Download'):
       st.session_state['button'] = False

Happy Streamlit-ing :balloon:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.