General question about how to distribute files in a project

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?

Much appreciated!!!

Hi @Ivan_Schuster,

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.”

@Charly_Wargnier, @dataprofessor, and @blackary might have thoughts to share on this as well!

1 Like

Hi @Ivan_Schuster

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:

Hope this helps!

Best regards,
Chanin

2 Likes

@dataprofessor @Caroline Thanks for the answers!

It seems like the right way to distribute the modules/files when we deal with somewhat big projects, is like this GitHub - dataprofessor/multipage-app-starter-kit

Again, thanks a lot for the answers :slight_smile:

2 Likes

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