├── .gitignore ├── now.json ├── app.py └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | venv 3 | -------------------------------------------------------------------------------- /now.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "builds": [ 4 | { 5 | "src": "app.py", 6 | "use": "@now/python" 7 | } 8 | ], 9 | "routes": [ 10 | { 11 | "src": "(.*)", 12 | "dest": "app.py" 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | from pprint import pformat 2 | 3 | 4 | async def app(scope, receive, send): 5 | await send( 6 | { 7 | "type": "http.response.start", 8 | "status": 200, 9 | "headers": [[b"content-type", b"text/plain"],], 10 | } 11 | ) 12 | await send( 13 | {"type": "http.response.body", "body": pformat(scope).encode("utf8"),} 14 | ) 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # asgi-scope 2 | 3 | A tiny application for understanding ASGI scope 4 | 5 | Example: https://asgi-scope.now.sh/path?qs=hello 6 | 7 | {'client': ('172.29.0.10', 34784), 8 | 'headers': [[b'host', b'asgi-scope.now.sh'], 9 | [b'x-forwarded-host', b'asgi-scope.now.sh'], 10 | [b'x-real-ip', b'199.188.193.220'], 11 | [b'x-forwarded-for', b'199.188.193.220'], 12 | [b'x-forwarded-proto', b'https'], 13 | [b'x-now-id', b'fb6gw-1527863960919-mjYC9OJ9WTsfnw4EiRTDmMst'], 14 | [b'x-now-log-id', b'mjYC9OJ9WTsfnw4EiRTDmMst'], 15 | [b'x-zeit-co-forwarded-for', b'199.188.193.220'], 16 | [b'connection', b'close'], 17 | [b'user-agent', 18 | b'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko' 19 | b'/20100101 Firefox/60.0'], 20 | [b'accept', 21 | b'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=' 22 | b'0.8'], 23 | [b'accept-language', b'en-US,en;q=0.5'], 24 | [b'accept-encoding', b'gzip, deflate, br'], 25 | [b'upgrade-insecure-requests', b'1']], 26 | 'http_version': '0.0', 27 | 'method': 'GET', 28 | 'path': '/path', 29 | 'query_string': b'qs=hello', 30 | 'scheme': 'http', 31 | 'server': ('172.28.0.10', 8000), 32 | 'type': 'http'} 33 | 34 | See also https://github.com/django/asgiref/blob/master/specs/www.rst 35 | --------------------------------------------------------------------------------