MCPcopy
hub / github.com/encode/starlette / __call__

Method __call__

starlette/routing.py:176–193  ·  view source on GitHub ↗

A route may be used in isolation as a stand-alone ASGI app. This is a somewhat contrived case, as they'll almost always be used within a Router, but could be useful for some tooling and minimal apps.

(self, scope: Scope, receive: Receive, send: Send)

Source from the content-addressed store, hash-verified

174 raise NotImplementedError() # pragma: no cover
175
176 async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
177 """
178 A route may be used in isolation as a stand-alone ASGI app.
179 This is a somewhat contrived case, as they'll almost always be used
180 within a Router, but could be useful for some tooling and minimal apps.
181 """
182 match, child_scope = self.matches(scope)
183 if match == Match.NONE:
184 if scope["type"] == "http":
185 response = PlainTextResponse("Not Found", status_code=404)
186 await response(scope, receive, send)
187 elif scope["type"] == "websocket": # pragma: no branch
188 websocket_close = WebSocketClose()
189 await websocket_close(scope, receive, send)
190 return
191
192 scope.update(child_scope)
193 await self.handle(scope, receive, send)
194
195
196class Route(BaseRoute):

Callers

nothing calls this directly

Calls 5

matchesMethod · 0.95
handleMethod · 0.95
PlainTextResponseClass · 0.90
WebSocketCloseClass · 0.90
updateMethod · 0.45

Tested by

no test coverage detected