Skip to content

Flask heroku #3915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions docs/Flask/11-Flask app on Heroku.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
id: Deploy Python Flask App on Heroku
title: how to deploy a flask app on Heroku
sidebar_label: Flask App on Heroku
sidebar_position: 11
tags: [flask, python, heroku ]
description: In this tutorial, you will learn about deployment offlask app on Heroku.
---

Flask is based on the Werkzeug WSGI toolkit and Jinja2 template engine. Both are Pocco projects. This article revolves around how to deploy a flask app on Heroku. To demonstrate this, we are first going to create a sample application for a better understanding of the process.

The Prerequisites are-
1.Python
2.pip
3.Heroku CLI
4.Git

### Deploying Flask App on Heroku

Let’s create a simple flask application first and then it can be deployed to heroku. Create a folder named “eflask” and open the command line and cd inside the “eflask” directory. Follow the following steps to create the sample application for this tutorial.

# STEP 1 :
Create a virtual environment with pipenv and install Flask and Gunicorn .

# STEP 2 :
Create a “Procfile” and write the following code.

# STEP 3 :
Create “runtime.txt” and write the following code.

# STEP 4 :
Create a folder named “app” and enter the folder

# STEP 5 :
Create a python file, “main.py” and enter the sample code.

# STEP 6 :
Get back to the previous directory “eflask”.Create a file“wsgi.py” and insert the following code.

# STEP 7 :
Run the virtual environment.

# STEP 8 :
Initialize an empty repo, add the files in the repo and commit all the changes.

# STEP 9 :
Login to heroku CLI

# STEP 10 :
Push your code from local to the heroku remote.
File renamed without changes.
Loading