Sidebar is not working in server but working in local

Hi,

I’m trying to create an app using Streamlit and it is working fine locally but when I deploy the app on a server it is not showing the sidebar navigation and getting the error:

Page not found

You have requested page /closings, but no corresponding file was found in the app’s pages/ directory. Running the app’s main page.

My file structure is the docker container > main app > pages > 1_closing.py. I’m creating tabs and here is the sample code:

    st.markdown(
    """
    <style>
    .tab-links {
        display: flex;
        justify-content: flex-end;
        gap: 2px;
    }
    .tab-links a {
        text-decoration: none;
        padding: 8px 16px;
        background-color: #d0d0d0;
        color: black;
        border-radius: 5px;
        font-size: 16px;
    }
    .tab-links a:hover {
        background-color: #767779;
    }


    </style>
    <div class="tab-links">
        <a href="/closings" target="_self">Closings</a>
        <a href="/openings" target="_self">Openings</a>
    </div>
    """,
    unsafe_allow_html=True,
    )

Can someone please help?

Notably, your error message says “page /closings” instead of “pages/closings” (with an s). Do you have a typo in a page path within your app?

Also, you have “closing” and “closings” which may be conflicting. I recommend double checking for a missing or extra character in general.

Hi @mathcatsand

  1. I’m not sure why it says page /closings but my file path is /docker/pages/closings.
  2. It was a typo here while posting the issue but not in the actual file name therefore this is all set.

Can you please advise what else the issue could be? I’ve spent more than three days on this, but I’ve not found a solution yet, as it works locally but not on the server.

Did you check your file name? You also have “closing” in your filename vs “closings” in the href.

If it’s not that, can you link to your repo? Some small discrepancy like this can cause this, so it’d be best to see the source.

(As far as working locally but not the server, I’d double check that everything is fully synced. After that, the most common source of error is file path handling, but you are starting a new session by routing the URL instead on using a Python command, so I don’t see the usual problem of switching between Windows and Linux paths from the bit that I can see.)

As for the “s” in pages, that was my mistake. The expected error is “… requested page /closings…” (a reference to the URL pathname, not the file path). So I’m left with only the “s” after “closing” that might be missing in one spot.

Hi @mathcatsand, I’ve resolved the issue. The issue was not about the file naming but how the files were handled in Dockerfile where instead of including just the primary file, all python files should have been included. I’ll mark this resolved. Thank you very much!

1 Like

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