Skip to main content

AnyQuart

Quart runs on Asyncio and when you want to run it on Trio event loop you use quart-trio extension.

AnyQuart is Quart running on AnyIO. It is a fork of Quart 0.20.1.

Differences from Quart

AnyQuart and Quart are essentially the same thing. The only difference is the name and the internals(Asyncio replaced with AnyIO). This also means the testing setup changes, which is explained in the Testing section below.

  • Works with both asyncio and Trio code via AnyIO, giving you structured concurrency out of the box.
  • Uses Anycorn instead of Hypercorn as the development server.
  • aiofiles dropped, AnyIO's file I/O is used instead.
  • pytest-asyncio replaced by AnyIO pytest plugin.
  • Runs on Python 3.10+ .

Usage

You will have to replace quart with anyquart and Quart with AnyQuart.

Install from PyPI using an installer such as pip. Requires Python 3.10+.

$ pip install anyquart

Save the following as app.py.

from anyquart import AnyQuart, websocket, render_template

app = AnyQuart(__name__)

@app.route("/")
async def hello():
    return await render_template("index.html")

@app.route("/api")
async def json():
    return {"hello": "world"}

@app.websocket("/ws")
async def ws():
    while True:
        await websocket.send("hello")
        await websocket.send_json({"hello": "world"})
$ anyquart run
 * Running on http://127.0.0.1:5000 (CTRL + C to quit)

Testing

Pytest requires a plugin to run asynchronous test functions and fixtures. Quart uses pytest-asyncio, while AnyQuart uses AnyIO's pytest plugin. You will need to specify which backend your tests run on via the anyio_backend fixture and decorate your asynchronous tests with @pytest.mark.anyio.

import pytest

from app import app

@pytest.fixture()
def anyio_backend():
    return "trio" # you can replace with "asyncio"

@pytest.fixture()
def test_client():
    return app.test_client()

@pytest.mark.anyio
async def test_do_something(test_client) -> None:
    response = await test_client.get("/")
    assert response.status_code == 200
    assert await response.json == {"hello": "world"}

Refer to the Quart documentation for more details.

Contributing

Issues and Pull Requests are welcome.

Contributors ✨

See All Contributors

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anyquart-0.2.0.tar.gz (64.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anyquart-0.2.0-py3-none-any.whl (77.9 kB view details)

Uploaded Python 3

File details

Details for the file anyquart-0.2.0.tar.gz.

File metadata

  • Download URL: anyquart-0.2.0.tar.gz
  • Upload date:
  • Size: 64.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for anyquart-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0e7e6bc2a3ac4bc841185747819abcfe809b224a4c3e84e0397104d728d761de
MD5 383058ef9c49d29c878e799effae5b21
BLAKE2b-256 008131344a757ff28ac0a0c83281b4bec8f455724795547a985156cf740f369d

See more details on using hashes here.

Provenance

The following attestation bundles were made for anyquart-0.2.0.tar.gz:

Publisher: publish.yaml on EmmanuelNiyonshuti/anyquart

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file anyquart-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: anyquart-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 77.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for anyquart-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4a4a96fa1ca6e0897d4bc7cb56287f9626abd47d1fe62c5005a28997be4ba6e6
MD5 68e1ce2daee3578c1fa746a41b34a826
BLAKE2b-256 75187098204b5750eb01a2a327984e37191dbf867305ba607eda51d16083fca7

See more details on using hashes here.

Provenance

The following attestation bundles were made for anyquart-0.2.0-py3-none-any.whl:

Publisher: publish.yaml on EmmanuelNiyonshuti/anyquart

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page