Use Heroku To Deploy An App

Heroku is extensively used because of it’s power to facilitate a quick app launch, to be more official, it ” runs and manages applications written in Ruby, Node.js, Java, Python, Clojure, Scala, Go and PHP”, Google App Engine is also providing similar service, while Heroku, now a subsidiary of Salesforce is edging out.

Following the detailed walk through at its website:

$ sudo snap install heroku – classic

$ heroku login

$git clone https//

$cd python-getting-started

##deploy the app

$heroku create

$git push heroku master

##now app is deployed, ensure that at least one instance of the app is running

$ heroku ps:scale web=1

##to visit the app at the URL generated by its app name

##as a handy shortcut, open it as follows

$ heroku open

##view the log

$ heroku logs –tail

##define a procfile

##procfile is a text file in the root directory

##to explicitly declare waht command should be executed to start the app

web: gunicorn gettingstarted.wsgi –log-file –

##check how many dynos are running

$ heroku ps

$ heroku ps:scale web=1

##declare app dependencies

##The requirements.txt file lists the app dependencies together

$ pip install -r requirements.txt

$ pip list #to see other dependencies instaleld

##now run the app locally

$ python collectstatic

$ heroku local web -f

##to push local changes

$ pip install requests

##and then add it to requirments.txt file:

  •  django
  •  gunicorn
  •  django-heroku
  •  requests

##add import requests to hello/ file

##modify the index method to make use of the module

def index(request):

    r = requests.get(‘’)


    return HttpResponse(‘<pre>’ + r.text + ‘</pre>’)

$ heroku local

$ git add .

$ git commit -m “Demo”

$ git push heroku master

$ herok open

##start a console

$ heroku run python shell

##The Python shell is running in the context of your app and all its dependencies. so one can type in python commands interactively direclty

##To get a real feel for how dynos work, you can create another one-off dyno and run

$ heroku run bash

##Each dyno has its own ephemeral filespace, populated with your app and its dependencies

exit to exit the dyno

##To set the config var on Heroku, execute the following

$ heroku config : set TIMES=2

##view the config vars

$ heroku config

##use the free Heroku Postgres add-on that was automatically provisioned when your app was deployed

$ heroku addons

$ heroku pg

so, if the app is deployed at , then go to /db to find the database.

#to create tables

$ heroku run python migrate

once you have the postgres installed locally, type the following to view db

$ heroku pg:psql

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.