How to deploy Flask App on Heroku.
Heroku is a platform as a service (PaaS) that enables developers to build, run, and operate applications entirely in the cloud.
Prerequisites
. Python
. pip
. Heroku CLI
. Git
Step:- 1
create a project folder and move to that folder by using the below command
mkdir flask_app
cd flask_app
Step:- 2
create a virtual environment by using the below command and move to that environment.
virtualenv envname
.\medium\Scripts\activate
Step:- 3
create a simple flask app or if you have already created one, use that one.
from flask import Flask
app = Flask(__name__)
@app.route("/")
def Home():
return "<h1>Hii Reader</h1>"
Step:- 4
create requirement.txt file
pip3 freeze > requirements.txt
Step:- 5
Initialize an empty repo, add the files in the repo and commit all the changes.
git init
git add .
git commit -m "Initial Commit"
Step:- 6
. Create account on heroku
. install heroku cli
. login to heroku using cli by using command "heroku login"
. create procfile using git bash
by using command "echo "web: gunicorn app:app" > Procfile"
. create app on heroku by using command "heroku create app_name"
. finally push your app to heroku remote
by using command "git push heroku master"
Thank you for reading !!!
If you enjoy this article and would like to Buy Me a Coffee, please click here.
you can connect with me on Linkedin.