St.empty() doesn't work

Hi, please find below my code; when I do Login i want to see the sidebar(it works) but in the main space I want to see just the word Hello instead the 2 forms.

supabase: Client = create_client(url, key)
st.title("Detector!")
st.markdown('<style>h1{color: orange; text-align: center;}</style>', unsafe_allow_html=True)
placeholder = st.empty()


placeholder.info("Please inser your username and password or create a new account")

col1, col2 = st.columns(2)
with col1:
    with st.form(key="login"):
        username = st.text_input(label="username")
        password = st.text_input(label="Password")
        if st.form_submit_button(label="Login"):
            data = supabase.auth.sign_in_with_password({"email": username, "password": password})
            if data:
                placeholder.empty()
                st.write("Hello!")
                st.sidebar.title(f"Welcome {username}")
                if st.sidebar.button("Logout"):
                    res = supabase.auth.sign_out()
                if st.sidebar.button("Refresh"):
                    placeholder.empty()
with col2:
    with st.form(key="Signup"):
        username = st.text_input(label="username")
        password = st.text_input(label="Password")
        if st.form_submit_button(label="Signup"):
            data = supabase.auth.sign_up({"email": username, "password": password})
            if data:
                st.write("Account created, please check your email to activate your account")
                placeholder.empty()
1 Like

If I change the code like this, received the error message: ‘setIn’ cannot be called on an ElementNode

What I try to achieve is that after login i need to show a different page/code with an input box and a button to run a function and show the result.

placeholder = st.empty()


placeholder.info("Please inser your username and password or create a new account")

with placeholder:
    col1, col2 = st.columns(2)
    with col1:
        with st.form(key="login"):
            username = st.text_input(label="username")
            password = st.text_input(label="Password")
            if st.form_submit_button(label="Login"):
                data = supabase.auth.sign_in_with_password({"email": username, "password": password})
                if data:
                    placeholder.empty()
                    st.write("Hello!")
                    st.sidebar.title(f"Welcome {username}")
                    if st.sidebar.button("Logout"):
                        res = supabase.auth.sign_out()
                    if st.sidebar.button("Refresh"):
                        placeholder.empty()
    with col2:
        with st.form(key="Signup"):
            username = st.text_input(label="username")
            password = st.text_input(label="Password")
            if st.form_submit_button(label="Signup"):
                data = supabase.auth.sign_up({"email": username, "password": password})
                if data:
                    st.write("Account created, please check your email to activate your account")
                    placeholder.empty()

Hi, we’re you able to find the answer?

1 Like

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