diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2022-01-23 17:13:49 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2022-01-23 17:13:49 +0300 |
commit | d4ccff8141cc4325d5ffc8890a7be96c0a7f12e7 (patch) | |
tree | c426dceeaf31822530032382d0b147e2ba0e378b /server.py | |
parent | app.py: fix loginctl output parsing (diff) | |
download | linux-status-d4ccff8141cc4325d5ffc8890a7be96c0a7f12e7.tar.gz linux-status-d4ccff8141cc4325d5ffc8890a7be96c0a7f12e7.zip |
dump exceptions to browser's console
Diffstat (limited to 'server.py')
-rwxr-xr-x | server.py | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -12,8 +12,9 @@ import argparse import http.server import os import sys +import traceback -from app import Request +from app import Request, Response DEFAULT_PORT = 18101 @@ -31,11 +32,12 @@ class RequestHandler(http.server.SimpleHTTPRequestHandler): return super().do_GET() try: response = request.process() + response.write_to_request_handler(self) except: - self.send_response(http.server.HTTPStatus.INTERNAL_SERVER_ERROR) - self.end_headers() + status = http.server.HTTPStatus.INTERNAL_SERVER_ERROR + response = Response(traceback.format_exc(), status) + response.write_to_request_handler(self) return - response.write_as_request_handler(self) def parse_args(args=None): |