MCPcopy
hub / github.com/plotly/dash / __call__

Method __call__

dash/backends/_fastapi.py:208–254  ·  view source on GitHub ↗
(self, scope: Scope, receive: Receive, send: Send)

Source from the content-addressed store, hash-verified

206 await response(scope, receive, send)
207
208 async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
209 # Handle lifespan events (startup/shutdown)
210
211 if scope["type"] == "lifespan":
212 try:
213 dash_app = get_app()
214 dash_app.backend._setup_catchall()
215 except Exception: # pylint: disable=broad-exception-caught
216 traceback.print_exc()
217 await self._initialize_dev_tools()
218 await self.app(scope, receive, send)
219 return
220
221 # Non-HTTP/WebSocket scopes pass through
222 if scope["type"] != "http":
223 await self.app(scope, receive, send)
224 return
225
226 # Non-Dash routes pass through to avoid consuming body stream
227 path = scope["path"]
228 prefix = self.dash_app.config.routes_pathname_prefix
229 dash_prefix = prefix.rstrip("/") + "/_dash-"
230 if (
231 not path.startswith(dash_prefix)
232 and path != prefix
233 and path != prefix.rstrip("/")
234 ):
235 await self.app(scope, receive, send)
236 return
237
238 # HTTP request handling
239 request = Request(scope, receive=receive)
240 token = set_current_request(request)
241
242 try:
243 await self._setup_timing(request)
244 await self._run_before_hooks()
245
246 await self.app(scope, receive, send)
247
248 await self._run_after_hooks()
249 self._finalize_timing(request)
250
251 except Exception as e: # pylint: disable=W0718
252 await self._handle_error(e, scope, receive, send)
253 finally:
254 reset_current_request(token)
255
256
257class FastAPIDashServer(BaseDashServer[FastAPI]):

Callers

nothing calls this directly

Calls 10

_initialize_dev_toolsMethod · 0.95
_setup_timingMethod · 0.95
_run_before_hooksMethod · 0.95
_run_after_hooksMethod · 0.95
_finalize_timingMethod · 0.95
_handle_errorMethod · 0.95
get_appFunction · 0.90
set_current_requestFunction · 0.85
reset_current_requestFunction · 0.85
_setup_catchallMethod · 0.80

Tested by

no test coverage detected