From 376b9c05f9277e5a5a80c4c9210fde5aaecf67aa Mon Sep 17 00:00:00 2001 From: Alberto Torres Date: Thu, 29 Aug 2024 00:43:37 +0200 Subject: [PATCH] Add port argument to simple_server.py --- scripts/simple_server.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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()