diff --git a/scripts/simple_server.py b/scripts/simple_server.py index 0fdc78c..928a56e 100755 --- a/scripts/simple_server.py +++ b/scripts/simple_server.py @@ -3,6 +3,7 @@ """Use instead of `python3 -m http.server` when you need CORS and SharedArrayBuffer""" from http.server import HTTPServer, SimpleHTTPRequestHandler +import sys class CORSRequestHandler(SimpleHTTPRequestHandler): def end_headers(self): @@ -12,5 +13,8 @@ class CORSRequestHandler(SimpleHTTPRequestHandler): self.send_header('Cache-Control', 'no-store, no-cache, must-revalidate') return super(CORSRequestHandler, self).end_headers() -httpd = HTTPServer(('', 8003), CORSRequestHandler) +port = 8003 +if len(sys.argv) > 1: + port = int(sys.argv[1]) +httpd = HTTPServer(('', port), CORSRequestHandler) httpd.serve_forever()