Flask v2.2.0 Release Notes

  • 🚀 Unreleased

    • Add new customization points to the Flask app object for many previously global behaviors.

      • flask.url_for will call app.url_for. :issue:4568
      • flask.abort will call app.aborter. Flask.aborter_class and Flask.make_aborter can be used to customize this aborter. :issue:4567
      • flask.redirect will call app.redirect. :issue:4569
    • Refactor register_error_handler to consolidate error checking. Rewrite some error messages to be more consistent. :issue:4559

    • 🖨 Use Blueprint decorators and functions intended for setup after registering the blueprint will show a warning. In the next version, this will become an error just like the application setup methods. :issue:4571

    • before_first_request is deprecated. Run setup code when creating the application instead. :issue:4605

    • Added the View.init_every_request class attribute. If a view subclass sets this to False, the view will not create a new instance on every request. :issue:2520.

    • A flask.cli.FlaskGroup Click group can be nested as a sub-command in a custom CLI. :issue:3263

    • Add --app, --env, and --debug options to the flask CLI, instead of requiring that they are set through environment variables. :issue:2836

    • Add --env-file option to the flask CLI. This allows specifying a dotenv file to load in addition to .env and .flaskenv. :issue:3108

    • It is no longer required to decorate custom CLI commands on app.cli or blueprint.cli with @with_appcontext, an app context will already be active at that point. :issue:2410

    • SessionInterface.get_expiration_time uses a timezone-aware value. :pr:4645

    • View functions can return generators directly instead of wrapping them in a Response. :pr:4629

    • Add stream_template and stream_template_string functions to render a template as a stream of pieces. :pr:4629