i have change the port to 5000 and work fine, but now i have another problem …
Now the fastapi server go up:
but how i can access to the endpoint ?
I would need a way to publicly expose the created pages and endpoints. Does anyone know how I can do it?
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.
April 10, 2023, 12:40pm
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.
[Edited: see my update in following comment.]
April 12, 2023, 12:46am
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
You can see the app running here:
Updated source code on GitHub.