Streamlit is an open-source Python framework that is useful for quickly building and deploying data-centric web apps with dynamic frontends (link to documentation). A key benefit of using Streamlit is that AI scientists/engineers can create UI-based apps using just Python (a language they tend to be highly familiar with), rather than having to resort to JavaScript, HTML/CSS, etc. Streamlit use cases may include analytics dashboards that leverage Pandas data frames, visualization of geographical maps, and interactive ML services (see many more examples in the Streamlit app gallery here).
In this blog post, we will look at how to quickly deploy a Streamlit app on BTP, which can be especially useful for productizing company-internal data products. Fortunately, this SAP tutorial already describes how to deploy a "Hello World" Python app on BTP using Cloud Foundry, and we will use that tutorial as a basis for rest of this blog post. While that tutorial uses the Flask framework, we only need to make a few small modifications to the code to make it work for Streamlit. As such, in the following, we will assume that you are able to deploy the "Hello World" Flask app from that tutorial without any issues.
In order to modify the tutorial code to work with Streamlit, perform the following changes:
In server.py, replace all of the code with:
import streamlit as st
st.write("Hello world")In requirements.txt, add the following requirement:
streamlitIn manifest.yml, change the line describing the command to:
command: streamlit run server.py --server.port 8080Notice that the Streamlit app is exposed on port 8080.
And that's essentially it 😊
Now redeploy the app with cf push.
The app should load at the appropriate app url (e.g., https://<some_url_prefix>.cfapps.eu12.hana.ondemand.com/).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 48 | |
| 23 | |
| 20 | |
| 18 | |
| 16 | |
| 16 | |
| 13 | |
| 13 | |
| 13 | |
| 12 |