Running and deploying python apps on Heroku is pretty easy. I usually use and Jinja2 templates for a typical web server.

heroku login

  • Set the environment variables

heroku config:set PORT=8080

  • Heroku clone the app from created path.

heroku git:clone -a myapp

  • Create Procfile to tell heroku how to run the app

gedit Procfile

  • Put this into the Procfile: (Heroku assigns some random port every time it restarts the job so don’t hardcode the port here. It is highly like that heroku will fail to bind that port. Let it use its own port.)

python $PORT

gedit requirements.txt

  • Example content of requirements.txt (pip based installation will be done after pushing the code before deployment by heroku)
  • Deploy the app by using git:

    git add .

    git commit -m "Some commit"

    git push heroku master

  • Visit
  • To see the logs:

heroku logs

  • One last thing, you can use this site to monitor your application’s uptime by pinging it periodically. It will prevent your application to become idle on heroku.