Quart is a Python asyncio web microframework with the same API as Flask. Quart should provide a very minimal step to use Asyncio in a Flask app.
Quart can be installed via pip pip install
quart
and requires Python 3.6+. A minimal Quart example would be
from quart import Quart
app = Quart(__name__)
@app.route('/')
async def hello():
return '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.
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.
It should be possible to migrate to Quart from Flask by a find and
replace of flask
to quart
and then adding async
and
await
keywords. See the docs for full
details.