Werkzeug

The Swiss Army Knife For Python Web Developers

Debugging System

This document represents the status of the Werkzeug development version, which can be different from previous releases. If you are not using the latest version and you encounter problems look at the documentation shipped with Werkzeug.

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:

from werkzeug import DebuggedApplication, run_simple
from myapplication import application

application = DebuggedApplication(application, evalex=True)

run_simple('localhost', 5000, application)

This code spawns a debugging server on localhost:5000 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 the evalex feature enabled, since it can be used to execute code on the server!