MCPcopy
hub / github.com/encode/uvicorn / default_app

Function default_app

tests/middleware/test_proxy_headers.py:28–40  ·  view source on GitHub ↗
(scope: Scope, receive: ASGIReceiveCallable, send: ASGISendCallable)

Source from the content-addressed store, hash-verified

26
27
28async def default_app(scope: Scope, receive: ASGIReceiveCallable, send: ASGISendCallable) -> None:
29 scheme = scope["scheme"] # type: ignore
30 if (client := scope["client"]) is None: # type: ignore
31 client_addr = "NONE" # pragma: no cover
32 else:
33 host, port = client
34 with contextlib.suppress(ValueError):
35 if ipaddress.ip_address(host).version == 6:
36 host = f"[{host}]"
37 client_addr = f"{host}:{port}"
38
39 response = Response(f"{scheme}://{client_addr}", media_type="text/plain")
40 await response(scope, receive, send)
41
42
43def make_httpx_client(

Callers

nothing calls this directly

Calls 1

ResponseClass · 0.90

Tested by

no test coverage detected