/streamlit-on-heroku

A barebones Heroku python environment with Streamlit

Primary LanguagePython

👋

This is a minimal example of how to install Streamlit on Heroku.

Thanks to emunozlorenzo and Gilbert Tanner for previous documentation.

Example Streamlit UI screenshot

One-click deployment

If you have a heroku account and you just want to test this out, you can deploy with this button:

Deploy

If you want to actually set up a development environment, you'll need to create a repository.

Clone, edit and deploy a Streamlit site

  • Get a Heroku account
  • Install Heroku CLI
    • brew tap heroku/brew && brew install heroku
  • Authenticate the CLI locally: heroku login
  • Clone this repo into a directory like "my-project-name"
    • git clone git@github.com:christopherfrance/streamlit-on-heroku.git my-project-name
  • cd my-project-name
  • Edit setup.sh to use your email address.
  • Install python dependencies locally in a virtual environment using pipenv
    • pipenv install
  • Run streamlit app in the browser locally:
    • streamlit run app.py
  • Create the remote heroku projet:
    • heroku create
  • Commit your work:
    • git add .
    • git commit -m "Initial commit!"
  • Push the code to Heroku:
    • git push heroku master

It should install requirements automatically on push, and give you a live URL in your terminal.

You probably also want a normal repository on github. Don't rely on Heroku to work like a normal repository.

Change the origin remote to point to a new github project that you own.

  • Make your new repo the origin for your new project:
    • git remote rm origin
    • git remote add origin [address of your new project]
  • Push to github git push origin master

(Alternatively, fork this repo to get started, instead of cloning it.)

If you need to configure Heroku:

  • Set an environment variable: heroku config:set KEY=VALUE
  • Read about the Heroku CLI

If you have problems with this guide: