Zero to Streamlit Python app deployed on Heroku
Streamlit is an interesting Python framework targeted at data scientists, machine learning developers, and anyone working with data who wants to robustly present their work. It has an interesting processing model from the top down with no state and few other tricky application models. You can cache but that's about it. This doesn't limit you though and I'd recommend any developer looking to present machine learning models, big data reports etc. to have a look.
Streamlit is working on a one-click deploy system but for now I think Heroku is your easiest bet.
You'll need Python and pip installed as well as the Heroku CLI setup.
First let's setup a simple Python app with Streamlit and numpy ;
mkdir streamlit-heroku
cd streamlit-heroku
echo -e "streamlit==0.49.0
numpy==1.16.5" > requirements.txt
pip install -r requirements.txt
Now a basic Streamlit app;
echo -e "import streamlit as st
import numpy as np
st.title('A random chart')
chart = st.bar_chart(np.random.rand(10,5))
btn = st.button('Randomise!')
if btn:
chart.bar_chart(np.random.rand(10,5))" > app.py
Now run it locally;
streamlit run app.py
And you should see;
It doesn't get much easier in Python.
Now we want to deploy this to the web using Heroku. We need a Procfile
for Heroku to pick up the Python app and Heroku works best with git deployment;
echo 'web: streamlit run --server.enableCORS false --server.port $PORT app.py' > Procfile
git init
git add .
git commit -a -m 'Thunderbirds are go'
heroku create
git push heroku master
You should see;
And you should end up with a deployed app on a Heroku URL like; https://stark-headland-93224.herokuapp.com/
Streamlit provides many more UI widgets and you can learn about caching and other process model methods here .