featurepreneur
Published in

featurepreneur

How to Deploy a Flask app on Heroku? | Part - 1

In this Article, We gonna deploy a Flask app on Heroku

Let me show you, How to do that.

Let’s get started

1. Go to Heroku Website and Create a New Account.

2. Install Heroku CLI

3. Open Terminal and enter the below command.

heroku login

It will ask you to press any key to open up the browser.

Press enter, It will automatically open the browser.

Now, press the login button in the browser.

4. Create a new app by entering the below command. This will create a git repository in Heroku.

Note: The app name should be unique.

heroku apps:create your-project-name

5. Create a New Folder, Go inside it and Initialize it as Git Repository.

mkdir your-folder-name
cd your-folder-name
git init
heroku git:remote -a your-project-name

6. Create a Flask app

touch app.py
nano app.py

Write your code

A sample code is given below:

from flask import Flaskapp = Flask(__name__)

@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run(debug=True)

Press Ctrl + X and Enter.

7. Create Procfile and requirements.txt

Procfile

web: gunicorn app:app

requirements.txt

flask
gunicorn

8. Commit and push the files

git add .
git commit -am "make it better"
git push heroku master

It will start the deployment process and looks like this

... 
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: Done: 52.7M
remote: -----> Launching...
remote: Released v3
remote: https://{your-project-name}.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/{your-project-name}.git
ae85864..4e63b46 master -> master

Now, open the browser and paste the given URL of your app into the browser

https://{your-project-name}.herokuapp.com/

I hope this was helpful to you, I will see you in the next article on How to deploy a Dockerized Flask app in Heroku.

Thank you for reading this article.

--

--

--

Microprediction/Analytics for Everyone! We help volunteers to do analytics/prediction on any data!

Recommended from Medium

A New Look & What’s Coming Next…

Creating Modular Power-up Systems in Unity

Enter Chaos Magick-User

Creating HTML email templates for vRealize Automation Code Stream

Review For These Months

Laravel Policy

Software Testing And Testing Types/ [Software Development Engineer in Test Article Series Part 6]

My Architecture: Private Equity Platform on AWS Cloud

Investran Private Equity Platform on AWS Cloud

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
Hari Prasad

Hari Prasad

More from Medium

Convert your text file into CSV using Python

How to Track an Airplane with Python

How to create a Flake 8 Plugin

Philips Hue with python

Python philips hue