| 1 |
================================ |
| 2 |
How to use Django with Hypercorn |
| 3 |
================================ |
| 4 |
|
| 5 |
Hypercorn_ is an ASGI server that supports HTTP/1, HTTP/2, and HTTP/3 |
| 6 |
with an emphasis on protocol support. |
| 7 |
|
| 8 |
Installing Hypercorn |
| 9 |
==================== |
| 10 |
|
| 11 |
You can install Hypercorn with ``pip``: |
| 12 |
|
| 13 |
.. code-block:: shell |
| 14 |
|
| 15 |
python -m pip install hypercorn |
| 16 |
|
| 17 |
Running Django in Hypercorn |
| 18 |
=========================== |
| 19 |
|
| 20 |
When :pypi:`Hypercorn` is installed, a ``hypercorn`` command is available |
| 21 |
which runs ASGI applications. Hypercorn needs to be called with the |
| 22 |
location of a module containing an ASGI application object, followed |
| 23 |
by what the application is called (separated by a colon). |
| 24 |
|
| 25 |
For a typical Django project, invoking Hypercorn would look like: |
| 26 |
|
| 27 |
.. code-block:: shell |
| 28 |
|
| 29 |
hypercorn myproject.asgi:application |
| 30 |
|
| 31 |
This will start one process listening on ``127.0.0.1:8000``. It |
| 32 |
requires that your project be on the Python path; to ensure that run |
| 33 |
this command from the same directory as your ``manage.py`` file. |
| 34 |
|
| 35 |
For more advanced usage, please read the `Hypercorn documentation |
| 36 |
<Hypercorn_>`_. |
| 37 |
|
| 38 |
.. _Hypercorn: https://hypercorn.readthedocs.io/ |