Page redirect

Is there a way to redirect from page app_1 to page app_2, and hide page app_1

Here’s a simple implementation of a multipage app that you can modify for your use. Hope this helps:

import streamlit as st

def App1page():
st.write(“Showing app 1”)
if st.button(“Return to Main Page”):
st.session_state.runpage = main_page
st.experimental_rerun()

def App2page():
st.write(“Showing app 2”)
if st.button(“Return to Main Page”):
st.session_state.runpage = main_page
st.experimental_rerun()

def main_page():
st.write(“This is my main menu page”)
btn1 = st.button(“Show App1”)
btn2 = st.button(“Show App2”)

if btn1:
    st.session_state.runpage = App1page
    st.session_state.runpage()
    st.experimental_rerun()

if btn2:
    st.session_state.runpage = App2page
    st.session_state.runpage()
    st.experimental_rerun()

if ‘runpage’ not in st.session_state:
st.session_state.runpage = main_page
st.session_state.runpage()

Thank you for your help, but your are suggesting in your code to add a main page, in my case the main page is app1page.
I Have a login_page (main_page), I want to be redirected when I click login button to another app_page.

You can do a simple re-substitution of my code accordingly. (Use my code as a guideline to modify your code for the same functionality).

Yeah. This is called MultiPage App
Here is a simple guide I followed.

3 Likes

Hi, mate. I gonna check if this can be used to solve my problem. Cheers!

1 Like

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