ASGI (Asynchronous Server Gateway Interface) Specification
ASGI consists of two different components:
- A protocol server, which terminates sockets and translates them into connections and per-connection event messages.
- An application, which lives inside a protocol server, is instantiated once per connection, and handles event messages as they happen.
socket ---> protocol server -------> application
event
connection scope
ASGI connection:
- A connection scope, which represents a protocol connection to a user and survives until the connection closes.
- Events, which are sent to the application as things happen on the connection.
interface
network protocol servers <-------------> Python applications
(particularly web servers)
- Implementations
- Servers
Uvicorn:
A fast ASGI server based on uvloop and httptools. Supports HTTP/1 and WebSockets. - Application Frameworks
Starlette:
Starlette is a minimalist ASGI library for writing against basic but powerful Request and Response classes. Supports HTTP.
- Servers
Uvicorn: