File_uploader: how to navigate to a page just after?

Hello,

My app has two pages: a home page which shows some info and allows the user to load their data with st.file_uploader. Once the user uploaded their data, I would like to navigate automatically to the second page which does the processing.

Currently I show a link that the user has to click, like this:

if uploaded_file is not None:
    st.page_link(page='pages/1_Process.py', label='Start the processing')

I tried using on_change and switch_page but it does not work, as this causes the error ‘Calling st.rerun() within a callback is a no-op’.

Is there any way to achieve this?

Solved, it’s actually quite simple but I didn’t think about it:

uploaded_file = st.file_uploader("Choose a file", type=['xlsx'])

if uploaded_file is not None:
    st.switch_page("pages/1_Process.py")

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