From 7206298cd11714d7fc66ec7548ab6c1e6b6f793a Mon Sep 17 00:00:00 2001 From: John Doty Date: Mon, 28 Oct 2024 05:55:29 -0700 Subject: [PATCH] [dingus] Improve dev loop --- dingus/srvit.py | 24 +++++++----------------- makefile | 1 + 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/dingus/srvit.py b/dingus/srvit.py index 31b0c81..e4d8a72 100755 --- a/dingus/srvit.py +++ b/dingus/srvit.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 -import os +import pathlib +import socket from http.server import test, SimpleHTTPRequestHandler, ThreadingHTTPServer @@ -35,22 +36,9 @@ if __name__ == "__main__": metavar="ADDRESS", help="bind to this address " "(default: all interfaces)", ) - parser.add_argument( - "-d", - "--directory", - default=os.getcwd(), - help="serve this directory " "(default: current directory)", - ) - parser.add_argument( - "-p", - "--protocol", - metavar="VERSION", - default="HTTP/1.0", - help="conform to this HTTP version " "(default: %(default)s)", - ) parser.add_argument( "port", - default=8000, + default=8086, type=int, nargs="?", help="bind to this port " "(default: %(default)s)", @@ -58,6 +46,8 @@ if __name__ == "__main__": args = parser.parse_args() handler_class = MyHTTPRequestHandler + directory = pathlib.Path(__file__).parent + # ensure dual-stack is not disabled; ref #38907 class DualStackServer(ThreadingHTTPServer): @@ -68,12 +58,12 @@ if __name__ == "__main__": return super().server_bind() def finish_request(self, request, client_address): - self.RequestHandlerClass(request, client_address, self, directory=args.directory) + self.RequestHandlerClass(request, client_address, self, directory=str(directory)) test( HandlerClass=handler_class, ServerClass=DualStackServer, port=args.port, bind=args.bind, - protocol=args.protocol, + protocol="HTTP/1.0", ) diff --git a/makefile b/makefile index 3b9c4fb..a6d04c0 100644 --- a/makefile +++ b/makefile @@ -27,6 +27,7 @@ clean: .PHONY: dingus dingus: dingus/wheel/lrparsers-$(VERSION)-py3-none-any.whl + python3 ./dingus/srvit.py dingus/wheel/lrparsers-$(VERSION)-py3-none-any.whl: dist/lrparsers-$(VERSION)-py3-none-any.whl cp $< $@