{"id":2743,"library":"quart","title":"Quart","description":"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.","status":"active","version":"0.20.0","language":"en","source_language":"en","source_url":"https://github.com/pallets/quart/","tags":["web framework","asgi","async","flask-like","microframework"],"install":[{"cmd":"pip install quart","lang":"bash","label":"Core installation"},{"cmd":"pip install quart[dotenv]","lang":"bash","label":"With .env file support"}],"dependencies":[{"reason":"To load files in an asyncio compatible manner.","package":"aiofiles","optional":false},{"reason":"To manage signals.","package":"blinker","optional":false},{"reason":"To manage command-line arguments.","package":"click","optional":false},{"reason":"Recommended ASGI server for development and production.","package":"hypercorn","optional":false},{"reason":"For signing secure cookies.","package":"itsdangerous","optional":false},{"reason":"For template rendering.","package":"jinja2","optional":false},{"reason":"For markup rendering.","package":"markupsafe","optional":false},{"reason":"As the basis of many Quart classes.","package":"werkzeug","optional":false},{"reason":"Support for loading environment variables from .env files.","package":"python-dotenv","optional":true}],"imports":[{"note":"Quart's API is Flask-compatible, but imports must be from `quart`.","wrong":"from flask import Flask","symbol":"Quart","correct":"from quart import Quart"},{"note":"Use `quart.request` for the global request object within Quart applications.","wrong":"from flask import request","symbol":"request","correct":"from quart import request"}],"quickstart":{"code":"from quart import Quart\n\napp = Quart(__name__)\n\n@app.route('/')\nasync def hello():\n    return 'Hello, Quart!'\n\n# To run this, save as app.py and execute: hypercorn app:app","lang":"python","description":"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`)."},"warnings":[{"fix":"Upgrade Python to version 3.9 or higher.","message":"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.","severity":"breaking","affected_versions":">=0.20.0"},{"fix":"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.","message":"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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Run your application with an ASGI server, e.g., `hypercorn app:app` or `uvicorn app:app` (if Uvicorn is installed).","message":"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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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`).","message":"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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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`).","message":"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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}