Quart extends the Flask-API by adding support for
- HTTP/1.1, including chunked transfer-encoded requests and pipelining.
- HTTP/2, including the ability to server push.
Quart can be installed via pip
pip install quart and requires Python 3.6+. A minimal Quart example would be
from quart import Quart, websocket app = Quart(__name__) @app.route('/') async def hello(): return 'hello' @app.websocket('/ws') async def ws(): while True: await websocket.send('hello') app.run()
if the above is in a file called
app.py can be run via
python app.py. To deploy in a production setting see the docs.
API Compatibility with Flask
The Flask API can be described as consisting of the Flask public and private APIs and Werkzeug upon which Flask is based. Quart is designed to be fully compatible with the Flask public API (aside from async and await keywords). Thereafter the aim is to be mostly compatible with the Flask private API and to provide no guarantees about the Werkzeug API.
Migrating from Flask
It should be possible to migrate to Quart from Flask by a find and replace of
quart and then adding
await keywords. See the docs for full details.