%(config_help)s
Pecan offers support for interactive debugging by installing the backlash package:
pip install backlash
...and reloading this page.
Traceback
WSGI Environment
''' % {'config_help': __CONFIG_HELP__} # noqa
debug_template = Template(debug_template_raw)
class DebugMiddleware(object):
def __init__(self, app, *args, **kwargs):
self.app = app
def __call__(self, environ, start_response):
try:
return self.app(environ, start_response)
except Exception as exc:
# get a formatted exception
out = StringIO()
print_exc(file=out)
# get formatted WSGI environment
formatted_environ = pformat(environ)
# render our template
result = debug_template.render(
traceback=out.getvalue(),
environment=formatted_environ
)
# construct and return our response
response = Response()
if isinstance(exc, HTTPException):
response.status_int = exc.status
else:
response.status_int = 500
response.unicode_body = result
return response(environ, start_response)