how do you guys run your streamlit apps? do you run them from home.py (for example, with home being a page), or you create a main.py (which isnt a page) and this file runs all the pages and manages everything?
I’m rewritting my app and I want to make sure I’m doing it in the right way. Could you perhaps share examples on how you distribute files in your projects, and if you use main/app.py files instead of running the app from Home.py (home being a page) share a code snippet of it?
Great question! Personally, I don’t there’s necessary one right answer to this – it depends on the size of your project, your own preferences, and the purpose of the project. In my own medium-sized projects, I usually create something similar to home.py, but I can definitely see the value of having a main.py file that isn’t a page for a larger project.
This feels like a relevant place to also share @blackary’s st_pages project which is a very cool tool you can use “to set the page names, order, and icons (and optionally group the pages into sections) in a multipage Streamlit app from your code without having to rename the files.”
Thanks for the question! I agree with @Caroline in that there is no right or wrong answer on this and it’s much of a personal preference or what works best in each unique situation.
For me, if an app is relatively simple then it’ll stay as a single page app while if it is more complicated, I could add more organization into the app via columns or expander box. For more complex apps, it may evolve into a multi-page app (the Home.py being a page as you had mentioned).
Here are the app template that I use on a daily basis:
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.