blackary / st_pages

An experimental version of Streamlit Multi-Page Apps
MIT License
456 stars 76 forks source link

Page not found: no corresponding file was found #80

Closed jozkotrapko closed 9 months ago

jozkotrapko commented 9 months ago

According to the documentation i should be able to hide page using hide_pages and then open it anyway via URL link as they are hidden via CSS only.

You can now pass a list of page names to hide_pages to hide pages dynamically for each user. Note that these pages are only hidden via CSS, and can still be visited by the URL. However, this could be a good option if you simply want a way to visually direct your user where they should be able to go next.

But when I try to open this hidden page via URL, I get:

Page not found You have requested page /example, but no corresponding file was found in the app's pages/ directory. Running the app's main page.

I get an error via streamlit whenever I try to open the URL "http://localhost:8501/example" with this code:

from st_pages import show_pages, hide_pages, Page

show_pages(
    [
        Page("home.py"),
        Page("pages/test.py"),
    ]
)

hide_pages(
    [
        Page("pages/example.py")
    ]
)

Can anyone help? Thank you!

blackary commented 9 months ago

Sorry, this is a bit confusing, but hide_pages doesn't take a list of Page objects, but takes a list of page names. You also can only add pages that have actually been added to the sidebar through show_pages.

So, the following code should work:

from st_pages import show_pages, hide_pages, Page

show_pages(
    [
        Page("home.py"),
        Page("pages/test.py"),
        Page("pages/example.py"),
    ]
)

hide_pages(
    [
        "Example",
    ]
)

I'll update the README to be more clear about how to use hide pages

miukki commented 5 months ago

nice!