Английская Википедия:Asynchronous Server Gateway Interface

Материал из Онлайн справочника
Версия от 17:17, 3 февраля 2024; EducationBot (обсуждение | вклад) (Новая страница: «{{Английская Википедия/Панель перехода}} {{Notability|date=December 2023}} {{Short description|Calling convention for web servers}} {{Infobox | name = Asynchronous Server Gateway Interface | title = ASGI Specification |header1 = | label1 = Version | data1 = 3.0 |header2 = | label2 = Developer | data2 = ASGI Team |header3 = | label3 = Release date | data3 = 2019-03-04<ref>{{cite web|url=https://asgi.readthedocs.io/en/lat...»)
(разн.) ← Предыдущая версия | Текущая версия (разн.) | Следующая версия → (разн.)
Перейти к навигацииПерейти к поиску

Шаблон:Notability Шаблон:Short description Шаблон:Infobox The Asynchronous Server Gateway Interface (ASGI) is a calling convention for web servers to forward requests to asynchronous-capable Python programming language frameworks, and applications. It is built as a successor to the Web Server Gateway Interface (WSGI).

Where WSGI provided a standard for synchronous Python application, ASGI provides one for both asynchronous and synchronous applications, with a WSGI backwards-compatibility implementation and multiple servers and application frameworks.

Example

An ASGI-compatible "Hello, World!" application written in Python:

async def application(scope, receive, send):
    event = await receive()
    ...
    await send({"type": "websocket.send", ...})

Where:

Web Server Gateway Interface (WSGI) compatibility

ASGI is also designed to be a superset of WSGI, and there's a defined way of translating between the two, allowing WSGI applications to be run inside ASGI servers through a translation wrapper (provided in the asgiref library). A threadpool can be used to run the synchronous WSGI applications away from the async event loop.

See also

Шаблон:Portal

References

Шаблон:Reflist

External links

Шаблон:Python (programming language) Шаблон:Python web frameworks Шаблон:Web frameworks