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.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking âAccept allâ, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.