Quart
Quart is a Python ASGI (Asynchronous Server Gateway Interface) web microframework, designed to be fully API compatible with Flask while providing native asynchronous functionality. It supports HTTP/1.1, HTTP/2, and WebSockets, making it suitable for modern, high-performance web applications. Currently at version 0.20.0, Quart maintains a regular release cadence with a focus on bug fixes and new features.
Warnings
- breaking Quart 0.20.0 dropped support for Python 3.8. Users on Python 3.8 or earlier must upgrade their Python version to 3.9+ before upgrading to Quart 0.20.0.
- gotcha Migrating from Flask requires explicitly making view functions `async def` and using `await` for asynchronous operations. While Quart maintains Flask's API, its ASGI foundation mandates `async`/`await` for non-blocking I/O within view functions. Many Flask extensions may not work directly without `quart_flask_patch` or an async-compatible alternative.
- gotcha The `app.run()` method is for development purposes only and should not be used in production. For production deployments, an ASGI server like Hypercorn (which is a dependency) or Uvicorn must be used to serve the Quart application.
- gotcha Calling synchronous/blocking I/O operations (e.g., traditional database drivers, `requests` library) directly within an `async def` view function without `await` or offloading them to a thread pool will block the event loop, severely degrading performance. Quart's async nature benefits from truly asynchronous libraries.
- gotcha For features like caching, specific database integrations, or WebSocket functionality, additional libraries are often required beyond the basic `quart` install. For example, `quart-session` for sessions, `redis` or `python-memcached` for caching backends, or an async ORM.
Install
-
pip install quart -
pip install quart[dotenv]
Imports
- Quart
from quart import Quart
- request
from quart import request
Quickstart
from quart import Quart
app = Quart(__name__)
@app.route('/')
async def hello():
return 'Hello, Quart!'
# To run this, save as app.py and execute: hypercorn app:app