You will not have access to local IP addresses on Streamlit Cloud. I think you will need a different method of deployment where you have network control.
You should deploy the FastAPI server part of the application standalone in another cloud. The sample above as is, is only suitable for local development.
In Streamlit Cloud the Streamlit front end app would have to mediate all communications with the FastAPI server, because only Streamlit’s server (may) have access to localhost:5000. It’s something I could try with that sample later.
I updated the app to start FastAPI on 127.0.0.1:5000. Calls are now routed to the 127.0.0.1:5000 endpoints, and the FastAPI server can be shutdown (and restarted).
In conclusion, for apps deployed in Streamlit Cloud:
The server-side code can access a FastAPI server running on localhost (specifically 127.0.0.1) which I tested with a new endpoint that returns a JSON response.
Client-side links of course can’t access the FastAPI server running on 127.0.0.1 in the cloud environment.
There are plenty of use cases that can use this simple FastAPI integration approach
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.