Add port argument to simple_server.py
This commit is contained in:
parent
447896b56e
commit
376b9c05f9
|
@ -3,6 +3,7 @@
|
||||||
"""Use instead of `python3 -m http.server` when you need CORS and SharedArrayBuffer"""
|
"""Use instead of `python3 -m http.server` when you need CORS and SharedArrayBuffer"""
|
||||||
|
|
||||||
from http.server import HTTPServer, SimpleHTTPRequestHandler
|
from http.server import HTTPServer, SimpleHTTPRequestHandler
|
||||||
|
import sys
|
||||||
|
|
||||||
class CORSRequestHandler(SimpleHTTPRequestHandler):
|
class CORSRequestHandler(SimpleHTTPRequestHandler):
|
||||||
def end_headers(self):
|
def end_headers(self):
|
||||||
|
@ -12,5 +13,8 @@ class CORSRequestHandler(SimpleHTTPRequestHandler):
|
||||||
self.send_header('Cache-Control', 'no-store, no-cache, must-revalidate')
|
self.send_header('Cache-Control', 'no-store, no-cache, must-revalidate')
|
||||||
return super(CORSRequestHandler, self).end_headers()
|
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()
|
httpd.serve_forever()
|
||||||
|
|
Loading…
Reference in a new issue