MCPcopy Index your code
hub / github.com/plotly/dash / serve_callback

Method serve_callback

dash/backends/_flask.py:253–290  ·  view source on GitHub ↗
(self, dash_app: Dash)

Source from the content-addressed store, hash-verified

251
252 # pylint: disable=unused-argument
253 def serve_callback(self, dash_app: Dash):
254 def _dispatch():
255 body = request.get_json()
256 # pylint: disable=protected-access
257 cb_ctx = dash_app._initialize_context(body)
258 func = dash_app._prepare_callback(cb_ctx, body)
259 args = dash_app._inputs_to_vals(cb_ctx.inputs_list + cb_ctx.states_list)
260 ctx = copy_context()
261 partial_func = dash_app._execute_callback(
262 func, args, cb_ctx.outputs_list, cb_ctx
263 )
264 response_data = ctx.run(partial_func)
265 if asyncio.iscoroutine(response_data):
266 raise Exception(
267 "You are trying to use a coroutine without dash[async]. "
268 "Please install the dependencies via `pip install dash[async]` and ensure "
269 "that `use_async=False` is not being passed to the app."
270 )
271 return cb_ctx.dash_response.set_response(data=response_data)
272
273 async def _dispatch_async():
274 body = request.get_json()
275 # pylint: disable=protected-access
276 cb_ctx = dash_app._initialize_context(body)
277 func = dash_app._prepare_callback(cb_ctx, body)
278 args = dash_app._inputs_to_vals(cb_ctx.inputs_list + cb_ctx.states_list)
279 ctx = copy_context()
280 partial_func = dash_app._execute_callback(
281 func, args, cb_ctx.outputs_list, cb_ctx
282 )
283 response_data = ctx.run(partial_func)
284 if asyncio.iscoroutine(response_data):
285 response_data = await response_data
286 return cb_ctx.dash_response.set_response(data=response_data)
287
288 if dash_app._use_async: # pylint: disable=protected-access
289 return _dispatch_async
290 return _dispatch
291
292 def register_timing_hooks(self, _first_run: bool):
293 # Define timing hooks inside method scope and register them

Callers 1

_setup_routesMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected