Flask 1.0 Released

Posted Python数据之道

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Flask 1.0 Released相关的知识,希望对你有一定的参考价值。

一直想提升下英语水平,后续将不定期转发一些英文文章;

本文来自:https://www.palletsprojects.com/blog/flask-1-0-released/


The Pallets team is pleased to release Flask 1.0.

The Flask framework has been stable for a long time. A little more than 8 years after the first commit, the version number finally reflects that. 1.0 comes with a significant number of changes representing over a year of work.

  • Dropped support for Python 2.6 and 3.3.

  • The CLI is more flexible. FLASK_APP can point to an app factory, optionally with arguments. It understands import names in more cases where filenames were previously used. It automatically detects common filenames, app names, and factory names. FLASK_ENV describes the environment the app is running in, like development, and replaces FLASK_DEBUG in most cases. See the docs to learn more.

  • If python-dotenv is installed, the flask CLI will load environment variables from .flaskenv and .env files rather than having to export them in each new terminal.

  • The development server is multi-threaded by default to handle concurrent requests during development.

  • flask.ext, which was previously deprecated, is completely removed. Import extensions by their actual package names.

  • Accessing missing keys from request.form shows a more helpful error message in debug mode, addressing a very common source of confusion for developers.

  • Error handlers are looked up by code then exception class, on the blueprint then application. This gives more predictable control over handlers, including being able to handle HTTPException.

  • The behavior of app.logger has been greatly simplified and should be much easier to customize. The logger is always named flask.app, it only adds a handler if none are registered, and it never removes existing handlers. See the docs to learn more.

  • The test_client gained a json argument for posting JSON data, and the Response object gained a get_json method to decode the data as JSON in tests.

  • A new test_cli_runner is added for testing an app's CLI commands.

  • Many documentation sections have been rewritten to improve clarity and relevance. This is an ongoing effort.

  • The tutorial and corresponding example have been rewritten. They use a structured layout and go into more detail about each aspect in order to help new users avoid common issues and become comfortable with Flask.

There are many more changes throughout the framework. Read the full changelog to understand what changes may affect your code when upgrading.

JSON Security Fix

Flask previously decoded incoming JSON bytes using the content type of the request. Although JSON should only be encoded as UTF-8, Flask was more lenient. However, Python includes non-text related encodings that could result in unexpected memory use by a request.

Flask will now detect the encoding of incoming JSON data as one of the supported UTF encodings, and will not allow arbitrary encodings from the request.

Install or Upgrade

Install from PyPI with pip:

pip install -U Flask



以上是关于Flask 1.0 Released的主要内容,如果未能解决你的问题,请参考以下文章

为啥代码片段在 matplotlib 2.0.2 上运行良好,但在 matplotlib 2.1.0 上引发错误

如何将 c、c++ 和 python 代码编译为“Released/Final”版本? [关闭]

Flask 1.0发布

Flask 编写http接口api及接口自动化测试

DbTool 2.0.0 Released

12_关于flask中的宏