Hello, I am trying to run my flask app and streamlit in same port
my flask has 0.0.0.0:5000/foo endpoint
and i want to run my streamlit app in 0.0.0.0:5000/foo2
is it possible ? if so how ?
Hello, I am trying to run my flask app and streamlit in same port
my flask has 0.0.0.0:5000/foo endpoint
and i want to run my streamlit app in 0.0.0.0:5000/foo2
is it possible ? if so how ?
Hi @qxlsz,
There are two ways to accomplish this, depending on your goals.
The more robust way to accomplish this would be to configure a web server like NGinx or Apache2 to serve as a reverse proxy that routes to different port numbers based on the endpoint names.
For example, you could put streamlit on port 8501 and your Flask app on port 5000, have your web server set up on any port you like (e.g. standard web port 80, or 8080, or 8888…), and then your requests would look like this:
Here’s a sample Nginx config by a Streamlit engineer (@monchier) that shows how to set up two Streamlit apps to be served by the same web server. You would just need to edit one of those config sections as appropriate for your Flask app.
The simpler method would be to set up your flask app to contain a page that is simply an iframe around your streamlit app.
So in that case, you’d run Flask on port 5000 and keep Streamlit on port 8501, and simply set up a Flask template with a line like:
<iframe src="http://yourdomain.com:8501"></iframe>
I hope that helps!
Thanks much
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.
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.
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.
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.