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

Method not_found

starlette/routing.py:606–619  ·  starlette/routing.py::Router.not_found
(self, scope: Scope, receive: Receive, send: Send)

Source from the content-addressed store, hash-verified

604 self.middleware_stack = cls(self.middleware_stack, *args, **kwargs)
605
606 async def not_found(self, scope: Scope, receive: Receive, send: Send) -> None:
607 if scope[class="st">"type"] == class="st">"websocket":
608 websocket_close = WebSocketClose()
609 await websocket_close(scope, receive, send)
610 return
611
612 class="cm"># If we're running inside a starlette application then raise an
613 class="cm"># exception, so that the configurable exception handler can deal with
614 class="cm"># returning the response. For plain ASGI apps, just return the response.
615 if class="st">"app" in scope:
616 raise HTTPException(status_code=404)
617 else:
618 response = PlainTextResponse(class="st">"Not Found", status_code=404)
619 await response(scope, receive, send)
620
621 def url_path_for(self, name: str, /, **path_params: Any) -> URLPath:
622 for route in self.routes:

Callers

nothing calls this directly

Calls 3

WebSocketCloseClass · 0.90
HTTPExceptionClass · 0.90
PlainTextResponseClass · 0.90

Tested by

no test coverage detected