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

Method setup_apis

dash/dash.py:855–879  ·  view source on GitHub ↗

Register API endpoints for all callbacks defined using `dash.callback`. This method must be called after all callbacks are registered and before the app is served. It ensures that all callback API routes are available for the Dash app to function correctly. Typical

(self)

Source from the content-addressed store, hash-verified

853 )
854
855 def setup_apis(self):
856 """
857 Register API endpoints for all callbacks defined using `dash.callback`.
858
859 This method must be called after all callbacks are registered and before the app is served.
860 It ensures that all callback API routes are available for the Dash app to function correctly.
861
862 Typical usage:
863 app = Dash(__name__)
864 # Register callbacks here
865 app.setup_apis()
866 app.run()
867
868 If not called, callback endpoints will not be available and the app will not function as expected.
869 """
870 for k in list(_callback.GLOBAL_API_PATHS):
871 if k in self.callback_api_paths:
872 raise DuplicateCallback(
873 f"The callback `{k}` provided with `dash.callback` was already "
874 "assigned with `app.callback`."
875 )
876 self.callback_api_paths[k] = _callback.GLOBAL_API_PATHS.pop(k)
877
878 # Delegate to the server factory for route registration
879 self.backend.register_callback_api_routes(self.callback_api_paths)
880
881 def _setup_plotlyjs(self):
882 # pylint: disable=import-outside-toplevel

Callers 1

Calls 3

DuplicateCallbackClass · 0.85
popMethod · 0.80

Tested by 1