diff options
Diffstat (limited to 'Lib/http/server.py')
-rw-r--r-- | Lib/http/server.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/http/server.py b/Lib/http/server.py index 31153f4..5b5ef0a 100644 --- a/Lib/http/server.py +++ b/Lib/http/server.py @@ -1082,10 +1082,12 @@ def test(HandlerClass = BaseHTTPRequestHandler, sa = httpd.socket.getsockname() print("Serving HTTP on", sa[0], "port", sa[1], "...") - httpd.serve_forever() - + try: + httpd.serve_forever() + except KeyboardInterrupt: + print("\nKeyboard interrupt received, exiting.") + httpd.server_close() + sys.exit(0) if __name__ == '__main__': - test(HandlerClass=BaseHTTPRequestHandler) test(HandlerClass=SimpleHTTPRequestHandler) - test(HandlerClass=CGIHTTPRequestHandler) |