This release will contain some new features such as some shorthand properties for the route, support async views, callbacks such as error handlers, and better CLI errors.
Flask 2.0 Upgradation and Installation
Install from PyPI with pip. For example, for Flask:
pip install -U Flask
Note: Flask 2.0 have dropped all support for Python 2 and 3.5, Now Python 3.6 is the minimum supported version.
Flask 2.0 Updates
Previously deprecated code has also been removed. Testing tools such as pytest enable showing deprecation warnings automatically and turn them into errors to see early what you may need to change in your project.
Note:
Over the next few weeks, the ecosystem around the projects will continue to update to improve compatibility as necessary. The team encourages you to use pip-compile and Dependabot to pin and control upgrades to your dependencies to avoid unexpected changes.
Support async views and error handlers
Support async views and other callbacks such as error handlers, defined with async def
. Regular sync views continue to work unchanged. ASGI features such as web sockets are not supported. We will continue exploring how to add more support for async.
Function to load config
A new Config.from_file
function to load config from any file format.
Route decorators for common HTTP API methods
Add route decorators for common HTTP API methods. For example, @app.post("/login")
is a shortcut for @app.route("/login", methods=["POST"])
.
Better CLI errors
Better CLI errors when an app could not be loaded. Running the development server shows errors immediately, they are only deferred on reloads.
Enables tab completion
The flask shell
command enables tab completion like the regular python shell does.
Caching based on content
While serving static files, browsers will cache based on file content rather than a 12-hour timer. That means changes to static content such as CSS styles will be reflected immediately on reload without needing to clear the cache.
Nested Blueprints
Blueprints can be nested under the other blueprints, allowing a more layered approach to organizing the application.
Original article by Rehmaanali
As your business grows, safeguarding the applications and systems it relies on involves a unique approach that balances accessibility with cybersecurity. At Raptor IT Consultants, our mission is to establish a foundation for your network resources that empowers users to work efficiently, while offering scalable, managed IT services that complement any business model; affordably. #raptoritnetwork