| 1 |
Quart-Trio |
| 2 |
========== |
| 3 |
|
| 4 |
|Build Status| |docs| |pypi| |python| |license| |
| 5 |
|
| 6 |
Quart-Trio is an extension for `Quart |
| 7 |
<https://github.com/pallets/quart>`__ to support the `Trio |
| 8 |
<https://trio.readthedocs.io/en/latest/>`_ event loop. This is an |
| 9 |
alternative to using the asyncio event loop present in the Python |
| 10 |
standard library and supported by default in Quart. |
| 11 |
|
| 12 |
Quickstart |
| 13 |
---------- |
| 14 |
|
| 15 |
QuartTrio can be installed via `pip |
| 16 |
<https://docs.python.org/3/installing/index.html>`_, |
| 17 |
|
| 18 |
.. code-block:: console |
| 19 |
|
| 20 |
$ pip install quart-trio |
| 21 |
|
| 22 |
and requires Python 3.13 or higher (see `python version support |
| 23 |
<https://quart.palletsprojects.com/en/latest/discussion/python_versions.html>`_ |
| 24 |
for reasoning). |
| 25 |
|
| 26 |
A minimal Quart example is, |
| 27 |
|
| 28 |
.. code-block:: python |
| 29 |
|
| 30 |
from quart import websocket |
| 31 |
from quart_trio import QuartTrio |
| 32 |
|
| 33 |
app = QuartTrio(__name__) |
| 34 |
|
| 35 |
@app.route('/') |
| 36 |
async def hello(): |
| 37 |
return 'hello' |
| 38 |
|
| 39 |
@app.websocket('/ws') |
| 40 |
async def ws(): |
| 41 |
while True: |
| 42 |
await websocket.send('hello') |
| 43 |
|
| 44 |
app.run() |
| 45 |
|
| 46 |
if the above is in a file called ``app.py`` it can be run as, |
| 47 |
|
| 48 |
.. code-block:: console |
| 49 |
|
| 50 |
$ python app.py |
| 51 |
|
| 52 |
To deploy in a production setting see the `deployment |
| 53 |
<https://quart-trio.readthedocs.io/en/latest/tutorials/deployment.html>`_ |
| 54 |
documentation. |
| 55 |
|
| 56 |
Contributing |
| 57 |
------------ |
| 58 |
|
| 59 |
Quart-Trio is developed on `GitHub |
| 60 |
<https://github.com/pgjones/quart-trio>`_. You are very welcome to |
| 61 |
open `issues <https://github.com/pgjones/quart-trio/issues>`_ or |
| 62 |
propose `merge requests |
| 63 |
<https://github.com/pgjones/quart-trio/merge_requests>`_. |
| 64 |
|
| 65 |
Testing |
| 66 |
~~~~~~~ |
| 67 |
|
| 68 |
The best way to test Quart-Trio is with Tox, |
| 69 |
|
| 70 |
.. code-block:: console |
| 71 |
|
| 72 |
$ pip install tox |
| 73 |
$ tox |
| 74 |
|
| 75 |
this will check the code style and run the tests. |
| 76 |
|
| 77 |
Help |
| 78 |
---- |
| 79 |
|
| 80 |
The `Quart-Trio <https://quart-trio.readthedocs.io>`__ and `Quart |
| 81 |
<https://quart.palletsprojects.com>`__ documentation are the best |
| 82 |
places to start, after that try searching `stack overflow |
| 83 |
<https://stackoverflow.com/questions/tagged/quart>`_, if you still |
| 84 |
can't find an answer please `open an issue |
| 85 |
<https://github.com/pgjones/quart-trio/issues>`_. |
| 86 |
|
| 87 |
|
| 88 |
.. |Build Status| image:: https://github.com/pgjones/quart-trio/actions/workflows/ci.yml/badge.svg |
| 89 |
:target: https://github.com/pgjones/quart-trio/commits/main |
| 90 |
|
| 91 |
.. |docs| image:: https://img.shields.io/badge/docs-passing-brightgreen.svg |
| 92 |
:target: https://quart-trio.readthedocs.io |
| 93 |
|
| 94 |
.. |pypi| image:: https://img.shields.io/pypi/v/quart-trio.svg |
| 95 |
:target: https://pypi.python.org/pypi/Quart-Trio/ |
| 96 |
|
| 97 |
.. |python| image:: https://img.shields.io/pypi/pyversions/quart-trio.svg |
| 98 |
:target: https://pypi.python.org/pypi/Quart-Trio/ |
| 99 |
|
| 100 |
.. |license| image:: https://img.shields.io/badge/license-MIT-blue.svg |
| 101 |
:target: https://github.com/pgjones/quart-trio/blob/main/LICENSE |