diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2022-03-11 22:55:25 +0500 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2022-03-11 22:55:25 +0500 |
commit | 853d48b48fc8123c403c5fb947732adb830b752d (patch) | |
tree | 545e0e13bb9488b9dff9b7a5cbfe8f5dcfe5d2d9 | |
parent | workflows/ci: run tests as root also (diff) | |
download | linux-status-853d48b48fc8123c403c5fb947732adb830b752d.tar.gz linux-status-853d48b48fc8123c403c5fb947732adb830b752d.zip |
server.py: minor refactoring
-rwxr-xr-x | server.py | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -40,6 +40,14 @@ class RequestHandler(http.server.SimpleHTTPRequestHandler): return +def make_server(port): + addr = ('', port) + server = http.server.HTTPServer + if sys.version_info >= (3, 7): + server = http.server.ThreadingHTTPServer + return server(addr, RequestHandler) + + def parse_args(args=None): if args is None: args = sys.argv[1:] @@ -54,12 +62,9 @@ def main(args=None): # It's a failsafe; this script is only allowed to serve the directory it # resides in. os.chdir(script_dir()) + args = parse_args(args) - addr = ('', args.port) - server = http.server.HTTPServer - if sys.version_info >= (3, 7): - server = http.server.ThreadingHTTPServer - httpd = server(addr, RequestHandler) + httpd = make_server(args.port) try: httpd.serve_forever() except KeyboardInterrupt: |