Deploy Flask App by Heroku (macOS)- A rigorous professor of cartography


OK! Let’s assume I am your friend and try to help you do this assignment clear and right :)

Heroku account


From now on, all work can be done by running just terminal (command line). Therefore, really to open your terminal??

Heroku CLI

Boomerang! Boomerang! Boomerang!

Heroku CLI installation

$ brew tap heroku/brew && brew install heroku

However, this instruction is shitty and cannot work on my terminal. Instead, Standalone installation is preferable.

$ curl | sh

Afterwards, you will see this: “heroku installed to /usr/local/bin/heroku”.

The next/third section is to satisfy the professor’s criteria to make sure you pass the assignment (build up local directory). You can alternatively copy your senior homework last year (visit my Github Template, fork it, clone it), or you can build them by following my instruction.

Make a local directory

$ mkdir {your-local-directory}

3. cd to your local directory

$ cd {your-local-directory}

Virtual environment

  1. go to your for project directory
$ cd {your-local-directory}

2. create a virtualenv

$ python -m venv venv/  # for python before python 3.0
$ python3 -m venv venv/ # for python after python 3.0

3. activate the virtualenv by

$ source venv/bin/activate

After the virtualenv is created and activated, the packages required now is time to add in

$ pip install flask 
$ pip install gunicorn


Then now, it comes to the most rigorous checkpoint from your professor. Even a tiny thing wrong would ruin the whole app-building process.

I don’t know why it should be named as “Procfile” but it just must be.

When you run Heroku and look at the application Logs, the final step I would mention at the end, if this statement comes up like this:

Procfile declares types -> (none)

It means you were screwed and you didn't make Procfile right. Then if it comes up like this:

Procfile declares types -> Web

Congrats! you made it!

Ok! It sounds frightening, but it is just the tip of the iceberg, so let’s unveil the confusing process….

Create Procfile

$ touch Procfile

Here is two things you should remind.

  1. Procfile is a file without .txt or any kinds of test file root.
  2. Procfile should be exactly “Procfile”. Lowercase is not allow.

Procfile written

web: gunicorn app:app

Let’s decode it a bit. web: gunicorn does call your app. app:app, the first app is your {your app name} and the second you don’t have to modify. For instance, if my app file called Then the Procfile should be written:

web: gunicorn mario:app


$ pip freeze > requirements.txt

Afterwards, the requirements.txt will contain all the dependent packages towards the virtual environment, in other words, the required packages you need for running the app.

{your flask app name}.py


You should have some skills for python programming. You have all skill to deal with the boss, so come to this part is a final relief for you.


Still! Some tips that I have used to success kill it that I should write a bit here. I suggest is to build a very very simple app, run it, make sure it works, and then extend it afterwards to your well-designed website.

Let’s me make a simple example here.

  1. Open your python file, for instance,
  2. Write this part in the file:
# in your python file
from flask import Flask
app = Flask(__name__)@app.route('/')def index():
return "<h1>Mario is my Spanish teacher </h1>"
if __name__ == '__main__':
# Threaded option to enable multiple instances for multiple user access support, port=5000)

OK! you made all of them independently. Congrats! Let’s do the final section!

OK! Those who referred my homework can come back and stay in line with other diligent students. It’s time for the fourth section, to hang in this assignment!

Deploy by HeroKu Git

Deploying on Heroku

Subsequently, it’s time to deploy your app on Heroku.

Please make sure you have read and done all works beforehand (!important), because the installation of Heroku CLI is necessary here and the local directory has to be well-prepared. If you have done them, let’s go/allons-y/vamos!

Connecting to Heroku CLI

  1. login:
$ heroku login

Heroku would use your browser to login in semi-automatically by clicking login on the browser.

2. create your app.

heroku create {app-name}

Note: they are certain rules like should start with lowercase blah blah... Please make sure you create sucessfully.

3. remote control to your heroku repository:

$ heroku git:remote -a {app-name}

Push files

  1. add files: “.” means add all files in the directory.
$ git add .

2. commit: save your shot

$ git commit -am "mario deploy"

3. upload the project by pushing it to Heroku:

$ git push heroku main 

Note: It can be done by master before, due to the respect of BLM…. you know that!

Wait….for a second let the website be built...and …Congratulations! Mission completed! But! But! But! The grade is posted somewhere. We should go and check if we get R or not.

The princess peach is encore escaping!!! Let’s open the browser, go to this link (your website) https://{app-name} and find her now!

Come and catch me in the next coding task! Jajaja!



Programmer | Agriculturist | Environmentalist

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store