Skip to content

Instantly share code, notes, and snippets.

@shengchiliu
Last active May 2, 2019 10:45
Show Gist options
  • Save shengchiliu/950f68a5b1f9005d331cff8041e354f1 to your computer and use it in GitHub Desktop.
Save shengchiliu/950f68a5b1f9005d331cff8041e354f1 to your computer and use it in GitHub Desktop.
Heroku for Flask Apps

Heroku for Flask Apps

Install Heroku, Flask and Gunicorn

1. Create Procfile and .gitignore Files

$ echo "web: gunicorn APP_NAME:app" >> Procfile

2. Create Requirements and Runtime Files

# List Python Dependencies
$ pip freeze > requirements.txt

# Specify Python Version
$ echo "python-2.7.14" >> runtime.txt

3. Submit Git Local Repository & Heroku Remote App

# Git Local
$ git init
$ git add .
$ git commit -m "initial commit"

# Heroku Remote
$ heroku login                  # enter your Heroku credentials
$ heroku create                 # use "git remote -v" to check the remote url
$ git push heroku master

# Show Heroku App in Browser
$ heroku open

# For An Existing Heroku App
$ heroku git:remote -a thawing-inlet-61413  # modified with your heroku app’s name

* Run Heroku Remote Bash

$ heroku run bash               # enter heroku remote bash

$ heroku run COMMAND            # command usage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment