How to Deploy Streamlit APP to Heroku?

Streamlit’s open-source app framework is the easiest way for data scientists and machine learning engineers to create beautiful, performant apps in only a few hours! All in pure Python. All for free.

But, if you want to deploy it online, how can we achieve it?

Just follow the steps below to get your first Streamlit APP online.

Notice: you should create your own Heroku account and install git in advance.

Step1. Prerequisite

Suppose that you have finished your awesome Streamlit APP, you still need to create 4 files in your project folder.

(runtime.txt,, Procfile, requirements.txt)

# To let heroku to know which programming language should use
# To do some automation task so that stremlit can work correctly on heroku
# please replace with your own email
mkdir -p ~/.streamlit/
echo "\
email = \"\"\n\
" > ~/.streamlit/credentials.toml
echo "\
headless = true\n\
port = $PORT\n\
" > ~/.streamlit/config.toml
# let heroku know which command to execute to run streamlit app
web: sh && streamlit run
# add the python package you will use inside your project
# for me, it would be:

Step2. Work with Heroku CLI and git

We have to set up Heroku environment before pushing our app to the cloud, please make sure that you have installed the Heroku CLI correctly

$ cd path/to/streamlit_project
$ heroku login
$ git init
$ heroku create
$ git add .
$ git commit -m "Enter your message here"
$ git push heroku master
$ heroku ps:scale web=1
$ heroku open


Written by

Machine Learning / Deep Learning / Python / Flutter

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store