Quart-Flask-Patch is a Quart extension that patches Quart to work with Flask extensions.
Project description
Quart-Flask-Patch is a Quart extension that patches Quart to work with Flask extensions.
Quickstart
Quart-Flask-Patch must be imported first in your main module, so that the patching occurs before any other code is initialised. For example, if you want to use Flask-Login,
import quart_flask_patch
from quart import Quart
import flask_login
app = Quart(__name__)
login_manager = flask_login.LoginManager()
login_manager.init_app(app)
Extensions known to work
The following flask extensions are tested and known to work with quart,
Flask-Limiter See also Quart-Rate-Limiter
Flask-Login See also Quart-Login or Quart-Auth
Flask-SQLAlchemy See also Quart-DB
Extensions known not to work
The following flask extensions have been tested are known not to work with quart,
Flask-CORS, as it uses app.make_response which must be awaited. Try Quart-CORS instead.
Flask-Restful as it subclasses the Quart (app) class with synchronous methods overriding asynchronous methods. Try Quart-OpenApi or Quart-Schema instead.
Caveats
Flask extensions must use the global request proxy variable to access the request, any other access e.g. via ~quart.local.LocalProxy._get_current_object will require asynchronous access. To enable this the request body must be fully received before any part of the request is handled, which is a limitation not present in vanilla flask.
Trying to use Flask alongside Quart in the same runtime will likely not work, and lead to surprising errors.
The flask extension must be limited to creating routes, using the request and rendering templates. Any other more advanced functionality may not work.
Synchronous functions will not run in a separate thread (unlike Quart normally) and hence may block the event loop.
Finally the flask_patching system also relies on patching asyncio, and hence other implementations or event loop policies are unlikely to work.
Contributing
Quart-Flask-Patch is developed on GitHub. If you come across an issue, or have a feature request please open an issue. If you want to contribute a fix or the feature-implementation please do (typo fixes welcome), by proposing a merge request.
Testing
The best way to test Quart-Flask-Patch is with Tox,
$ pip install tox
$ tox
this will check the code style and run the tests.
Help
The Quart-Flask-Patch documentation is the best places to start, after that try searching stack overflow or ask for help on gitter. If you still can’t find an answer please open an issue.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file quart_flask_patch-0.2.0.tar.gz
.
File metadata
- Download URL: quart_flask_patch-0.2.0.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1cb70333a08157c09b72eea21b903c670333857fb88f84113bc569e782dd7cb |
|
MD5 | f1cd7948a610ca106c89b901024dd921 |
|
BLAKE2b-256 | e4bf25542c14fb0b377e61e4eb0ee09f826b99f5fad60ac5badbaaae6ee8df4d |
File details
Details for the file quart_flask_patch-0.2.0-py2.py3-none-any.whl
.
File metadata
- Download URL: quart_flask_patch-0.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a1b744276d61f05d5d60982794984b0e683391c6e3fea5d1f6545781318330b |
|
MD5 | 6498e0fab0233b21becef60e1d287b89 |
|
BLAKE2b-256 | a65a85f0bc351c14c80ccd6f4aae7bdd2b69e503c41b3ba3646ff7c8565fa36a |