ASGI

もしASGIサーバ(訳注: ASGIはWSGIの後継を目指しているもので、非同期処理やWebSocketなどもサポートしようとしているものです)を使いたい場合、WSGIをASGIにするミドルウェアが必要になるでしょう。Flaskのasync と await の使用のサポートで使われているevent loopと統合しているため、asgirefのWsgiToAsgiアダプタが推奨されます。Flaskアプリを包む(wrap)ことでアダプタを使用できます。 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,

from asgiref.wsgi import WsgiToAsgi
from flask import Flask

app = Flask(__name__)

...

asgi_app = WsgiToAsgi(app)

そしてそれから、ASGIサーバ、例えばHypercornを使って、(上の例では)asgi_appを提供します、 and then serving the ``asgi_app`` with the ASGI server, e.g. using `Hypercorn <https://gitlab.com/pgjones/hypercorn>`_,

$ hypercorn module:asgi_app