# Deploying our app to Heroku
# In this video... (TL;DR)
List of all code changes made in this lecture: https://diff-store.com/diff/section10__10_deploy_app_heroku (opens new window)
Recap what we need in order to deploy a Flask app to Heroku: a GitHub repo, the
Every Python app also needs
requirements.txt: a file that contains the libraries the app needs in order to run. Heroku will install libraries from this file before running your app.
# Code written in this lecture
To deploy to Heroku, create a GitHub repo and upload your code.
We need to add two files to our repo:
Procfile holds the command to run in order to start our app. It also holds the type of Dyno that our app will use.
web: gunicorn "app:create_app()"
We're using a
web type of dyno, running the command
That runs the
create_app() function inside
app.py, and uses the resultant Flask app to pass to gunicorn, who can understand it and run it.
We need to tell Heroku what programming language to use. Here I'll write Python 3.9.6 because that's the version I was using at the time of writing.
If there's a later Python version, try your code with it locally first, and if it works, use it in Heroku as well.
More information available in the Heroku Python runtimes page (opens new window).
This is what my
Add those two files to your GitHub repo, and then let's create a project in Heroku. Link it to your GitHub repo as we've already seen, and deploy the
If you have any issues, you can look through the Heroku logs to find what the problem is!