From 932e8753916dfb2924b713eca3757958b2b1ea12 Mon Sep 17 00:00:00 2001 From: Real Python Bot <42617967+realpython-bot@users.noreply.github.com> Date: Sat, 5 Dec 2026 21:57:49 +0000 Subject: [PATCH] Sync python-flask-example-heroku with the updated tutorial Re-pin to Flask 3.1.3 and gunicorn 27.0.1 (tested on Python 3.15.2), add .python-version (force-added past the root .gitignore, since the tutorial tells readers to create it for Heroku), and expand the README with setup and usage. Co-Authored-By: Claude Opus 5.5 --- python-flask-example-heroku/.python-version | 1 + python-flask-example-heroku/README.md | 26 ++++++++++++++++++++ python-flask-example-heroku/requirements.txt | 15 +++++------ 3 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 python-flask-example-heroku/.python-version diff --git a/python-flask-example-heroku/.python-version b/python-flask-example-heroku/.python-version new file mode 100644 index 0000000000..93a848f968 --- /dev/null +++ b/python-flask-example-heroku/.python-version @@ -0,0 +1 @@ +3.15 diff --git a/python-flask-example-heroku/README.md b/python-flask-example-heroku/README.md index 8ee161149b..33ad561703 100644 --- a/python-flask-example-heroku/README.md +++ b/python-flask-example-heroku/README.md @@ -1 +1,27 @@ +# Deploying a Python Flask Example Application Using Heroku + Source files supporting the [Deploying a Python Flask Example Application Using Heroku](https://realpython.com/flask-by-example-part-1-project-setup/) article on [Real Python](https://realpython.com/). + +## Setup + +You'll need Python 3.10 or later. The tutorial was tested with Python 3.15, which is also the version that `.python-version` asks Heroku to install. + +Create and activate a virtual environment, then install the pinned dependencies: + +```console +$ python3 -m venv venv +$ source venv/bin/activate +(venv) $ python3 -m pip install -r requirements.txt +``` + +## Usage + +Run the app locally with Flask's development server: + +```console +(venv) $ SECRET_KEY=key-read-from-env-var flask run --debug +``` + +Then open `http://localhost:5000` in your browser. + +To deploy to Heroku, follow the tutorial. The `Procfile` tells Heroku to serve the app with Gunicorn, and `.python-version` pins the Python version. diff --git a/python-flask-example-heroku/requirements.txt b/python-flask-example-heroku/requirements.txt index 41959c78c3..83bdf44b06 100644 --- a/python-flask-example-heroku/requirements.txt +++ b/python-flask-example-heroku/requirements.txt @@ -1,7 +1,8 @@ -click==7.1.2 -Flask==1.1.2 -gunicorn==20.0.4 -itsdangerous==1.1.0 -Jinja2==2.11.2 -MarkupSafe==1.1.1 -Werkzeug==1.0.1 +blinker==1.9.0 +click==8.5.1 +Flask==3.1.3 +gunicorn==27.0.1 +itsdangerous==2.2.0 +Jinja2==3.1.6 +MarkupSafe==3.0.4 +Werkzeug==3.1.9