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.
pip install quartVerified import paths — ran on the pinned version, not inferred.
A minimal 'Hello, World!' Quart application. Routes are defined using `@app.route` decorators on `async def` functions, returning a string. For production, it's recommended to run with an ASGI server like Hypercorn (e.g., `hypercorn app:app`).
Upgrade Python to version 3.9 or higher.
Rewrite view functions to be `async def` and ensure all I/O bound operations within them use `await`. For extensions, check for `quart_` prefixed versions or use `quart_flask_patch` for compatibility where possible.
Run your application with an ASGI server, e.g., `hypercorn app:app` or `uvicorn app:app` (if Uvicorn is installed).
Use async-native libraries for database access (e.g., `asyncpg`, `motor`, `databases`), HTTP requests (`httpx`), and file operations (`aiofiles`). Alternatively, offload blocking calls to a thread pool (e.g., `loop.run_in_executor`).
Consult Quart's documentation or community resources to identify and install the correct async-compatible libraries for desired functionality (e.g., `pip install quart-session redis`).
pip install quart
Ensure your application object is named `app` (e.g., `app = Quart(__name__)`) in a file like `app.py` in your current directory, or set the `QUART_APP` environment variable: `export QUART_APP=your_module:your_app_instance`
Define the function as an asynchronous function using `async def`: `async def my_view(): await some_async_call()`
Always `await` asynchronous request attributes before accessing their content: `data = await request.get_json()` or `data = await request.json`