is this the established pattern? new to streamlit. ive made a few dashboards using streamlit behind a nginx ingress basic auth with the data feeds coming from a quick fastapi endpoint. works really well
ive gotta imagine some of you folks are doing the same. any pitfalls i should know about?
This is definitely my preferred solution approach. I usually start off with a Streamlit monolith to get a solution started and to test ideas. I use modular functions which can later be wrapped by FastAPI. Functions that will end up in the server layer should not use any Streamlit APIs, so a little care is required to keep the client UI parts separate from the server parts. The server functions always return literals or dict objects. To mimic st.cache behaviors in the server I use functools/lru_cache or diskcache/memoize. To mimic session state in the server I have a couple of classes and methods that behave the same way as st.session_state. Direct method calls to server functions in the UI tier are then replaced with REST API calls to server functions. As a bonus I often reuse the server functions via a CLI wrapper too, using typer.
However, these kinds of apps can’t be deployed easily to Streamlit Cloud if you wish to access the FastAPI from the external web as well as from the Streamlit app. I have some working code that will do this via Tornado, but it requires an additional mapping layer. I usually deploy these client/server apps in Heroku or another public cloud if local databases are involved.
i see. its fair to say i have no real “experience” with fastapi or streamlit but ive spend two weeks playing with them so i feel well enough experienced.
firstly. again, this shit is dope. i cant believe no one is using this. legit one of the coolest things ive randomly come across.
my deployment model is kinda convoluted but ultimately ive got an nginx basic auth thing going on with some jinja bs that im using to render my app. i saw you page some concept of pages. that seems a more direct route towards modularization
im finding this very intuitive. thank you so much. i feel like this is how i will express myself going forward
I think there are 10s of 1000s of developers using this (Streamlit), but not sure how many in production as those numbers are not available. Maybe the upcoming BUILD event will shed some light on this.
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.