aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/server.py
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2022-03-11 22:55:25 +0500
committerEgor Tensin <Egor.Tensin@gmail.com>2022-03-11 22:55:25 +0500
commit853d48b48fc8123c403c5fb947732adb830b752d (patch)
tree545e0e13bb9488b9dff9b7a5cbfe8f5dcfe5d2d9 /server.py
parentworkflows/ci: run tests as root also (diff)
downloadlinux-status-853d48b48fc8123c403c5fb947732adb830b752d.tar.gz
linux-status-853d48b48fc8123c403c5fb947732adb830b752d.zip
server.py: minor refactoring
Diffstat (limited to 'server.py')
-rwxr-xr-xserver.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/server.py b/server.py
index 0ebe5d5..914765d 100755
--- a/server.py
+++ b/server.py
@@ -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: