提交 1c3b53c5 编写于 作者: P pgjones

Update the docs on serving with ASGI

Whilst it has been possible to serve via an ASGI server for a while
(using WSGI to ASGI middleware/adapters) it hasn't added much. Now
though it makes sense to recommend the asgiref adapter as it
integrates with the same event loop used for async route handlers
etc...
上级 5c6a0f0c
ASGI
====
If you'd like to use an ASGI server you will need to utilise WSGI to
ASGI middleware. The asgiref
[WsgiToAsgi](https://github.com/django/asgiref#wsgi-to-asgi-adapter)
adapter is recommended as it integrates with the event loop used for
Flask's :ref:`async_await` support. You can use the adapter by
wrapping the Flask app,
.. code-block:: python
from asgiref.wsgi import WsgiToAsgi
from flask import Flask
app = Flask(__name__)
...
asgi_app = WsgiToAsgi(app)
and then serving the ``asgi_app`` with the asgi server, e.g. using
`Hypercorn <https://gitlab.com/pgjones/hypercorn>`_,
.. sourcecode:: text
$ hypercorn module:asgi_app
......@@ -31,3 +31,4 @@ Self-hosted options
mod_wsgi
fastcgi
cgi
asgi
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册