Initialise your git repo in the working directory with
$ git init
Initialise your pipenv environment by running
$ pipenv shell
Install the required packages for creation of the app and the deployment using Heroku
$ pipenv install flask, autoenv, gunicorn
Create a file called Procfile and add the following line
web: gunicorn app:app
Create a Heroku app using the Heroku CLI
$ heroku login
$ heroku create karomoweb-stage
Add the heroku remote to your git
$ git remote add stage [email protected]:karomoweb-stage.git
You can either connect Github to your Heroku app or using Heroku's remote to update your app
Create a config.py file and add the following code
import os
basedir = os.path.abspath(os.path.dirname(__file__))
class Config(object):
DEBUG = False
TESTING = False
CSRF_ENABLED = True
SECRET_KEY = 'this-really-needs-to-be-changed'
class ProductionConfig(Config):
DEBUG = False
class StagingConfig(Config):
DEVELOPMENT = True
DEBUG = True
class DevelopmentConfig(Config):
DEVELOPMENT = True
DEBUG = True
class TestingConfig(Config):
TESTING = True
Create an env file using
$ touch .env
Then add the following lines
pipenv shell
export APP_SETTINGS="config.DevelopmentConfig"
We set the Heroku environment variable by running
$ heroku config:set APP_SETTINGS=config.StagingConfig --remote stage
You can also go to Heroku deploy settings and set Autodeploy everytime the master branch or the github branch is updated