Running app locally .
Streamlit Version: 1.28.0
Python Python 3.9.18
Question : How to add session state here my requirements are as below :
When clicking the “Button 1” button will run the loop code and keep the DataFrame result on the screen even if you click the “Button 2” button, I want to use a session state variable and prevent the re-execution of the loop code when the “Download Result” button is clicked.
[whether the “Button 1” button has been clicked. You can do this by creating a session state variable and setting it to True when the “Button 2” button is clicked. Then, you can check the value of the session state variable before running the loop code. If the session state variable is True, you can skip the loop code and display the DataFrame result that is already in memory.]
Currently after clicking Download Result my dataframe got vanished from screen and rerunning my application . Please help me
Code :
if st.button(“Button 1”):
Entire code witin button 1:
st.download_button(
label="Button 2",
data=excel_file_data,
key="excel-download",
file_name="HPT_S1N_Support.xlsx",
)