================
Debugging System
================

Depending on the WSGI gateway/server, exceptions are handled differently but
most of the time exceptions go to stderr or the error log.

Since this is not the best debugging environment Werkzeug provides a WSGI
middleware that renders nice debugging tracebacks, optionally with an AJAX
based debugger (which allows to execute code in the context of the
traceback's frames).

Usage:

.. sourcecode:: python

    from myapplication import application
    from werkzeug.debug import DebuggedApplication
    from wsgiref.simple_server import make_server

    application = DebuggedApplication(application, evalex=True)
    
    srv = make_server('localhost', 4000, application)
    srv.serve_forever()

This code spawns a Debugging Server on `localhost:4000` with the debugger
enabled. If you set `evalex` to `False`, the debugger is disabled.

.. warning::

   Don't ever use the debugging middleware in a production environment since it
   can leak internal information that is part of the variable debug table. Even
   worse is a debugger with enabled `evalex` feature that can be used to execute
   code on the server!
