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: