Deploying a Flask Application to Heroku

Kavit (zenwraight)
techie
Published in
3 min readMar 24, 2021

--

Introduction

In this tutorial you will learn how to deploy a Flask application to Heroku. The app can be as simple as a “Hello World” app to a social media monitoring platform.

Building a REST API with Flask

I usually create a local virtual environment before moving forward with python web application development, that’s because I don’t want to cause discrepancies in old packages with new packages that I am going to install.

You can do so by running two commands:-

python -m venv venv/

This will create a folder named venv where you ran the above command. Then in order to start and enter the environment, type:-

source venv/bin/activate

Now that we are inside our virtual environment, let’s install our dependency and type in our sample code inside app.py file

pip install flask
pip install gunicorn
touch app.py

Flask is the framework that we will be using to develop our web app using python and Gunicorn is our server.

Code:-

--

--