Skip to main content

Deploying a Streamlit App on Heroku

1. Create Three Files

Procfile

Replace main.py with the entry point of your Streamlit app.

web: sh setup.sh && streamlit run main.py

requirements.txt

streamlit
--find-links https://download.pytorch.org/whl/torch_stable.html
torch==1.7.1+cpu
torchvision

setup.sh

mkdir -p ~/.streamlit

echo "[server]
headless = true
port = $PORT
enableCORS = false
" > ~/.streamlit/config.toml

2. Heroku Configuration

Tips:

$ heroku plugins:install heroku-accounts
$ heroku accounts:add account1
$ heroku accounts:set account2
$ heroku accounts:remove account2
$ heroku accounts

3. Deploy

  1. heroku create name
  2. git push heroku master # with valid commit