From c8823ae432d0c162183c82f05170095ab2f6a80a Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Wed, 3 Mar 2021 23:57:57 +0300 Subject: server.py: return status 500 on error in app.py --- server.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index 24ee72a..a76d2ca 100755 --- a/server.py +++ b/server.py @@ -16,7 +16,13 @@ class RequestHandler(http.server.SimpleHTTPRequestHandler): request = Request.from_http_path(self.path) except ValueError: return super().do_GET() - request.process().write_as_request_handler(self) + try: + response = request.process() + except: + self.send_response(http.server.HTTPStatus.INTERNAL_SERVER_ERROR) + self.end_headers() + return + response.write_as_request_handler(self) def main(): -- cgit v1.2.3