| 93 | |
| 94 | # Handle WSGI request |
| 95 | def handleRequest(self, env, start_response): |
| 96 | path = bytes(env["PATH_INFO"], "raw-unicode-escape").decode("utf8") |
| 97 | if env.get("QUERY_STRING"): |
| 98 | get = dict(cgi.parse_qsl(env['QUERY_STRING'])) |
| 99 | else: |
| 100 | get = {} |
| 101 | ui_request = UiRequest(self, get, env, start_response) |
| 102 | if config.debug: # Let the exception catched by werkezung |
| 103 | return ui_request.route(path) |
| 104 | else: # Catch and display the error |
| 105 | try: |
| 106 | return ui_request.route(path) |
| 107 | except Exception as err: |
| 108 | logging.debug("UiRequest error: %s" % Debug.formatException(err)) |
| 109 | return ui_request.error500("Err: %s" % Debug.formatException(err)) |
| 110 | |
| 111 | # Reload the UiRequest class to prevent restarts in debug mode |
| 112 | def reload(self): |