Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASGI interface module #116

Closed
Jaymon opened this issue Aug 13, 2021 · 3 comments · Fixed by #121
Closed

ASGI interface module #116

Jaymon opened this issue Aug 13, 2021 · 3 comments · Fixed by #121

Comments

@Jaymon
Copy link
Owner

Jaymon commented Aug 13, 2021

From the docs:

ASGI (Asynchronous Server Gateway Interface) is a spiritual successor to WSGI, intended to provide a standard interface between async-capable Python web servers, frameworks, and applications.

Heard about this from here:

If you are starting a new project, you might benefit from a newer and faster framework based on ASGI instead of WSGI (Flask and Django are WSGI-based).

...Also, if you want to use new technologies like WebSockets it would be easier (and possible) with a newer framework based on ASGI, like FastAPI or Starlette. As the standard ASGI was designed to be able to handle asynchronous code like the one needed for WebSockets.

Check out Starlette, Uvicorn, or FastAPI to see how it is implemented. It looks like FastAPI depends on Starlette, and Starlette is using Anyio as an underlying library. This module: asgiref also looks useful.

The current reference server is Daphne:

The current ASGI reference server, written in Twisted and maintained as part of the Django Channels project. Supports HTTP/1, HTTP/2, and WebSockets.

@Jaymon
Copy link
Owner Author

Jaymon commented Oct 11, 2021

#118

@Jaymon
Copy link
Owner Author

Jaymon commented Oct 11, 2021

Links I had open

Search

  • tornado or asgi
  • asgi daphne says version 3 but lools to be 2

@Jaymon
Copy link
Owner Author

Jaymon commented Dec 14, 2021

Some notes I had open while messing with Daphne:

daphne -b 0.0.0.0 -p 4000 asgi:application

pip install daphne

request object:
args (1) =
(
	0:
		{
			'type': "http",
			'http_version': "1.1",
			'method': "GET",
			'path': "/foo/bar",
			'raw_path': b'/foo/bar',
			'root_path': "",
			'scheme': "http",
			'query_string': b'',
			'headers':
				[
					0:
						(
							0: b'host',
							1: b'localhost:4000'
						),
					1:
						(
							0: b'user-agent',
							1: b'curl/7.58.0'
						),
					2:
						(
							0: b'accept',
							1: b'*/*'
						)
				],
			'client':
				[
					0: "127.0.0.1",
					1: 33958
				],
			'server':
				[
					0: "127.0.0.1",
					1: 4000
				],
			'asgi':
				{
					'version': "3.0"
				}
		}
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant