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.

Tests PyPI Python License t

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.1.tar.gz (64.6 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.1-py3-none-any.whl (78.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: anyquart-0.2.1.tar.gz
  • Upload date:
  • Size: 64.6 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.1.tar.gz
Algorithm Hash digest
SHA256 866008a4a3f3286f259e27451f5d4973112f43d5022d6fea99e9dc4ad87624e8
MD5 4b145d79a125c2143970724ff12a575e
BLAKE2b-256 69d85a7c8474dfe2aad5ee89207cd9fa01359a41f4e72733bd2a243e6a36f681

See more details on using hashes here.

Provenance

The following attestation bundles were made for anyquart-0.2.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: anyquart-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 78.1 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 daa56b0cab5a0f7a1eb23cc344a4b44b92822ac56f34715d086c4e1790c2f3a7
MD5 b39be733535d3c54d6d07c9250b37f83
BLAKE2b-256 6afea35b01f5da90841a78a437c8966dc15f4609107cedabe5c7f2e341c1f8af

See more details on using hashes here.

Provenance

The following attestation bundles were made for anyquart-0.2.1-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