Asgi Examples Save Abandoned

A collection of example ASGI applications

Project README

asgi-examples

ASGI (Asynchronous Server Gateway Interface) examples and information.

ASGI application example

Here are two examples of writing an ASGI application in its simplest form.

As a function


def app(scope):
    async def asgi(receive, send):
        await send(
            {
                "type": "http.response.start",
                "status": 200,
                "headers": [[b"content-type", b"text/plain"]],
            }
        )
        await send({"type": "http.response.body", "body": b"Hello, world!"})

    return asgi

As a class

class App:
    def __init__(self, scope):
        self.scope = scope

    async def __call__(self, receive, send):
        await send(
            {
                "type": "http.response.start",
                "status": 200,
                "headers": [[b"content-type", b"text/plain"]],
            }
        )
        await send({"type": "http.response.body", "body": b"Hello, world!"})

Frameworks / Adapters / Middlewares

Below are various frameworks, adapters, and middlewares that use ASGI.

Servers

Tools

Running the applications

An ASGI server is required to run the examples. For example, to run an application using uvicorn, use the following command:

$ uvicorn app:app

Reference

Below are links to various ASGI-related projects and information.

Specification

Misc

Discussions

Contributing

Please open an issue or pull request if you would like to contribute to the examples or README. The issue tracker may also be used for any informal ASGI-related discussions or questions.

Open Source Agenda is not affiliated with "Asgi Examples" Project. README Source: jordaneremieff/asgi-examples
Stars
43
Open Issues
0
Last Commit
5 years ago

Open Source Agenda Badge

Open Source Agenda Rating