From 98f100cc2d2e37b5ac7df08c1bf8b96592961b88 Mon Sep 17 00:00:00 2001 From: dahn Date: Fri, 1 Dec 2017 09:22:00 +0100 Subject: [PATCH] add address as parameter usefull for testing remote or trouble shooting network issues. --- simple-testing-server.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/simple-testing-server.py b/simple-testing-server.py index 805d47d..01b5874 100755 --- a/simple-testing-server.py +++ b/simple-testing-server.py @@ -4,6 +4,7 @@ import cgi +ADDRESS = "localhost" PORT = 8003 FILE_PREFIX = "." @@ -12,6 +13,8 @@ import argparse parser = argparse.ArgumentParser(description='A simple fake server for testing your API client.') + parser.add_argument('-a', '--address', type=str, dest="ADDRESS", + help='the interface/address to listen on; defaults to localhost') parser.add_argument('-p', '--port', type=int, dest="PORT", help='the port to run the server on; defaults to 8003') parser.add_argument('--path', type=str, dest="PATH", @@ -19,6 +22,8 @@ args = parser.parse_args() + if args.ADDRESS: + ADDRESS = args.ADDRESS if args.PORT: PORT = args.PORT if args.PATH: @@ -89,5 +94,5 @@ def do_POST(self): self.send_response(500) -server = HTTPServer(("localhost", PORT), JSONRequestHandler) +server = HTTPServer((ADDRESS, PORT), JSONRequestHandler) server.serve_forever()