Skip to content

Instantly share code, notes, and snippets.

@shu-yusa
Created September 24, 2017 06:27
Show Gist options
  • Save shu-yusa/6c04369c05e5cf84e57a4b233e841790 to your computer and use it in GitHub Desktop.
Save shu-yusa/6c04369c05e5cf84e57a4b233e841790 to your computer and use it in GitHub Desktop.
Heroku

Heroku tutorial

Prerequisite

  • a free Heroku account.
  • Python3.6.
  • pipenv installed locally. If not, install by pip install pipenv.
  • Postgresql installed locally. If not, install by brew install postgresql.

Setup

Install Heroku CLI from Getting Started on Heroku with Python | Heroku Dev Center.

Authenticate your Heroku account:

heroku login

Deploy the app

Clone sample project and move to the directory of the app:

git clone https://github.com/heroku/python-getting-started.git
cd python-getting-started
heroku create

You can confirm that a git remote heroku is created by

git remote
# heroku
# origin

Deploy code by

git push heroku master

Ensure that at least one instance is running:

heroku ps:scale web=1

Visit the app by

heroku open

You can view logs by

heroku logs --tail

Scale the app

You can check how many diynos are running by

heroku ps

Scale the number of web dynos to zero:

heroku ps:scale web=0

You will get an error message when you open the web page.

Scale it up again:

heroku ps:scale web=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment