Deployment issue

Good morning,

While testing locally my project(testing) using subprocess function to open/ run another page('run, it is working correctly. But when deploying it on streamlit, it not taking any action when clicking on the button.

Another test i did at deployment stage, trying to create as if a login page before accessing the analytical page, After inserting the credentials, when clicking on the log in button, not action is being taken. When it worked perfectly on localhost.

Can someone help me please

Hi @Kasarajen_Mootien and welcome to our community!

Could you please try to bring all your code under one roof by ditching the subprocess module and pulling the code from your other script into your main Streamlit app?


Hi @Charly_Wargnier, thank you for your fast response.

yes sure it is working as if a sidebar. But is it possible to have as if a login before the user can access the page please?

Kind regards,

1 Like

Thanks @Kasarajen_Mootien for the quick feedback!

So while Streamlit does not provide built-in support for user authentication, you can still create a simple login interface within your app. Hereโ€™s a very basic way of doing this:

Hereโ€™s the code:

import streamlit as st

def main():
    st.write("Welcome to the main application")  # This is the main application code

def check_password(stored_password, user_password):
    if stored_password == user_password:
        return True
        return False

def password_input():
    st.subheader("Login to the application")
    username = st.text_input("User Name")
    password = st.text_input("Password", type='password')
    return username, password

def login():
    username, password = password_input()

    if st.button("Login"):
        stored_password = "your_password"  # You can encrypt this password or store it securely somewhere
        if check_password(stored_password, password):
            st.write(f"Logged in as {username}")
            st.error("The password you entered is incorrect")


Is it what you are after?


Thank you.

At testing stage all works fine.

But i issue is becoming when i deploy it; after clicking on the log in button no action is been taken to redirect me toward the main page. So, the issue is the load of new page (run of another py code). Else the other time would be working fine.

Can you help please? Like a sample would have help; as with a log in that will redirect to a page that have multiple pages.

Thank you a lot again

Kind regards,

1 Like

Thanks for the mock-ups and feedback!

Itโ€™s a bit difficult to diagnose and advise without any benchmarked code, but as an alternative, hereโ€™s a simple function I created for my internal needs to apply a login to every single page of an MPA app.

import streamlit as st

# Hardcoded password
correct_password = "one"

def check_password():
    """Returns `True` if the user has the correct password."""

    # Initialize 'password_correct' if it's not in the session state
    if "password_correct" not in st.session_state:
        st.session_state["password_correct"] = False

    # If the password has already been entered correctly, don't ask again
    if st.session_state.password_correct:
        return True

    # Initialize 'password' if it's not in the session state
    if "password" not in st.session_state:
        st.session_state["password"] = ""

    def password_entered():
        """Checks whether a password entered by the user is correct."""
        if st.session_state.password == correct_password:
            st.session_state.password_correct = True
            st.session_state.password_correct = False

    # If the password is not correct, show input + error.
        "Please authenticate to access the pages",
    if st.session_state.password_correct:
        return True
    elif st.session_state.password:
        st.error("๐Ÿ˜• Password incorrect")
    return False

You would then call this on every page, this way, at the top of each page.

from password import check_password

if check_password():

Would that work as expected?

Let me know.


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