I am trying to upload a file. The upload button works fine, able to upload file but after upload the page refreshes and view is same page without login. Could someone please share ideas/approaches for multi page app where logged in is visible only after successful login. (Only Login and Signup are options in sidebar at every page.)
Code:
placeholder = st.empty()
buff, col, buff2 = placeholder.beta_columns([3, 9, 3])
col.write("---------------------------------------------")
uploaded_file = col.file_uploader("Upload the source data file", type=['csv'])
time.sleep(10)
if uploaded_file.data:
...
... rest of the code for uploaded file's processing
I tested with time.sleep() and the page remains as long as sleep lasts but does not reach the check for uploaded_file is not None
Is this a wrong approach since I want to have uploader within width of col?
Hi @Manu.This is a problem which doesn’t have a oficial solution, called SessionState. There are some workarounds the community created, you can check this out here:
While i was develop my streamlit app, i had a similar problem as you, but was with st.number_input. Recently streamlit launch a new feature called st.forms which the aim is prevent the input that are located inside this form do not refresh, you can check following the link below:
Here there is a snippet of my code which include maybe the problem you facing:
p_toleranciamento = st.number_input("Percentage of Tolerance (P or K): ")
t_tolerancia = st.number_input("Tolerance (T): ")
n_desvios_padroes = st.number_input("Number of Standard Deviation (w): ")
#qtd_pontos = st.number_input("Digite a Quantidade de Amostras (n): ")
# Botão para calcular o índice Cg
submit_button_1 = st.form_submit_button(label="Submit Values")
# Calculo do indice de capabilidade Cg:
if submit_button_1:
col1, mid, col2 = st.beta_columns([10,5,20])
with col1:
df2 = df.rename(columns={'AMOSTRA':'Samples'}, inplace=True)
Hi, thanks for you reply @feliperoque. And surely will check out Submit buttons and Forms and replace in the code.
I am already using SessionState to pass data along to multiple pages… The weird issue here seems to be the break in flow even after I upload file and process it on the same page. I hope this clears the question a bit more. As soon the file is uploaded the page sort of disappears even after having the process logic for it immediately after the file uploader.