I’d like to run some initialization code for my multi-page Streamlit application before the first page load. Is that possible?
The initialization logic only needs to run once, at service start (streamlit run app_init.py). I’m aware of @st.cache_resource, but the issue is that the caching can only be triggered by a page load. My app is headless, so I’d like to just set things up before the first page load. I guess I can open the page myself or send a request to warm up my app, but not great.
It would be amazing if the Streamlit server had a simple hook for us to define basic logic that runs once, on startup, such as loading environment variables, parsing configs, setup my database connections, load caches, wire up classes with DI etc.