Detect if Dash is running in debug mode

Hi all,

Is there a way (in code) to detect if Dash is running in debug mode?
I would like to build my own additional debug components (with their own callbacks etc) that are only available to the user when running in debug mode.

Possible avenues I can think of (but I wonder whether any of them is recommended)

  • app.server.debug boolean
  • app.config['DEBUG'] boolean

Hi @Wabiloo I asked our senior staff to try to offer some insight to your question. This is what they said:

If these components need to be in the layout and have callbacks attached, the challenge is that debug mode is normally set in app.run_server - long after the layout and callbacks are normally finalized. If you NEED to detect this from Python, it MIGHT be possible to use app.server.before_first_request(my_function) where my_function inspects app._dev_tools (could theoretically change in the future, but most likely will not).

On the JS side it might be easier: if you’ve enabled the devtools UI (which normally comes along with debug mode though in principle you can shut it off separately), then the whole app is wrapped in an extra div (in both cases the app is the highlighted element - first debug mode):


and not:


So you could make css rules: .my-selector {visibility: hidden} and #_dash-global-error-container .my-selector {visibility: visible} but then the components and callbacks always need to be registered.

Hope this helps,