Overview
Flask 2.3, released on April 26, 2023, drops Python 3.7 support and migrates to importlib for resource loading.
Main Features
Python 3.7 dropped
Flask 2.3 requires Python 3.8+ and takes advantage of modern features like assignment expressions (:=) and positional-only parameters.
python
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/api/greet', methods=['GET'])
def greet():
# Walrus operator (Python 3.8+)
if (name := request.args.get('name')):
return jsonify(message=f'Hello {name}!')
return jsonify(message='Hello World!')
importlib migration
Template and static file loading now uses importlib.resources instead of pkg_resources, improving startup times.
python
from flask import Flask, render_template
# Flask uses importlib.resources internally
# for loading templates and static files
app = Flask(__name__)
@app.route('/')
def home():
# Template loading is faster
return render_template('index.html')
# Blueprints also benefit from the improvement
from flask import Blueprint
api = Blueprint('api', __name__, url_prefix='/api')
