Hello,
I am trying to integrate streamlit app with flask app. what would be the recommendations.
I also want to save the rendered html file from streamlit so i can use flask.render_template to show the interative streamlit app inside flask.
Streamlit runs its own web server via the Tornado framework, and thereâs no good way to embed a Streamlit app inside a Flask server.
(Serving an interactive Streamlit app via flask.render_template isnât feasible, because Streamlit apps are not static; when you interact with your Streamlit app, it is re-running your Python code to generate new results dynamically.)
You could, however, run Streamlit alongside a Flask app (or possibly embed your Streamlit app inside an <iframe> thatâs served from your Flask app). But before I send you too far down a rabbithole, can you explain in more detail what youâre trying to achieve?
Would there be a possibility in the future to have an ability to host endpoints via the same Streamlit app? This could help merge / migrate Flask or other types of app into streamlit - I hope Iâm making sense. My question is similar but I want to also use the same server as an endpoint server/host.
Or do you recommend that we host a separate endpoint server and keep it separate from streamlit server?
It could be interesting to have the possibility as Bokeh does to use the function âserver_documentâ.
In bokeh in flask framework you could âcallâ this function
app1 = server_document(âhttp://localhost:5000/bokehapp1â) and then you can send app1 as variable of your flask template
render_template(â'index.html",app1=app1)
and in template {{app1}}
The app lives in a loop server from bokeh.server.server, and you can create app1, app2, app3 without problems as a graph api to your flask page.
As always is an idea. But integrating this type of tools in solid webframeworks (like django, flask, etcâŠ) itâs good idea as it let you develop solid webpages, and integrate advanced dynamic tools when required.
Youâre right, there are always ways that we might do things differently, but then it stops being Streamlit! Meaning, if you find Streamlit preferable to Django, Flask, Bokeh because itâs really easy to get started, then making Streamlit more like those other projects (which are all great in their own right!) brings us back to the original reason why Streamlit was created in the first place
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.