What IS Heroku
Short introduction to HEROKU
HEROKU is a popular Platform-as-a-Service provider (PaaS) which makes it easy for developers to deploy apps in different technologies and frameworks using a short learning curve. The platform support all major languages like Python, Ruby, Java, PHP, and popular frameworks: Flask, Django, Express.
To use effectively HEROKU we need to install the CLI, the command line interface that helps us to interact with the deployment platform.

How to start

    Create a FREE account on HEROKU platform
    Install the Heroku CLI that match your OS: Mac, Unix, or Windows
    Open a terminal window and authenticate via HEROKU login command:
      Type in terminal heroku login. This will open a new browser window where the LOGIN action must be confirmed
​
HEROKU - Sign Up page
HEROKU - Sign Up page
​
HEROKU - Instal CLI
HEROKU - Instal CLI
After the installation is complete, open a terminal window and type heroku -v to check if HEROKU CLI is usable.
1
$ heroku -v
2
$ heroku/7.42.13 win32-x64 node-v12.16.2
3
$ # The sample output returned by HEROKU CLI on a Windows PC
Copied!

​

HEROKU Sample Deployment

We can see HEROKU in action by using two samples FREE apps provided by AppSeed - Flask Black Dashboard. This popular Flask starter is provided with all assets required by HEROKU to be deployed in seconds. The relevant files:
Step #1 - Edit runtime.txt and specify the Python version to be used
1
python-3.6.10
Copied!
Step #2 - Edit Procfile, the HEROKU app bootstrapper
1
web: gunicorn run:app --log-file=-
Copied!
The above line instructs HEROKU to use the Gunicorn WSGI server to execute the WSGI app object, returned by run.py, located at the root of the project.
1
# Contents of run.py
2
from flask_migrate import Migrate
3
from os import environ
4
...
5
app = create_app( app_config )
6
Migrate(app, db)
7
# At this point, app is the WSGI object that Gunicorn expects.
Copied!
The gunicorn module must be also present in the requirements.txt file, along with other modules required by the app.
1
flask
2
flask_login
3
...
4
python-decouple
5
gunicorn # <--- The magic line
Copied!
With all configuration in place, we can start the deployment by typing a few lines in the terminal.
Step - #3 Clone the source code of target project
1
$ git clone https://github.com/app-generator/flask-black-dashboard.git
2
$ cd flask-black-dashboard
Copied!
Step - #4 HEROKU Login - this will trigger a new browser window
1
$ heroku login
Copied!
Step - #5 Create the app in HEROKU platform
1
$ # Create the app with a random name
2
$ heroku create
3
$
4
$ # Create app using a name
5
$ heroku create you-name-here
Copied!
Step - #5 Compile the app in the HEROKU environment
1
$ git push heroku master
Copied!
Step - #6 Open the app in the browser
1
$ heroku open
Copied!
At this point, the sample app should be visible in the browser.
Flask Dashboard - Black Design, free starter coded in Flask by AppSeed.

​

HEROKU troubleshooting

    First, make sure HEROKU CLI is accessible in the terminal. To check this type heroku -v in the terminal.
    Make sure the commands are typed inside source code directory
    heroku create used with an argument - Make sure that name is available in the HEROKU namespace.
​

HEROKU-ready apps

Starters provided by AppSeed are deployment-ready by default for many popular platforms - Docker, HEROKU and Gunicorn/Nginx.
Last modified 5mo ago