Skip to content

PS2 games in the browser: static recompilation to WebAssembly with a native runtime

C++

serve.py: let the game server listen on a chosen host

Riccardo Giorato1b557885e0c2
diff --git a/scripts/serve.py b/scripts/serve.py
index 31f6bd6..b4900dc 100755
--- a/scripts/serve.py
+++ b/scripts/serve.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""Serves a web build and a disc image with HTTP range requests.
-usage: serve.py <build dir> <disc image> [port] [--record <dir for unrecorded VU1 programs>]
+usage: serve.py <build dir> <disc image> [port] [--host address] [--record <dir for unrecorded VU1 programs>]
"""
import http.server
@@ -15,6 +15,11 @@ if '--record' in sys.argv:
at = sys.argv.index('--record')
RECORD = os.path.abspath(sys.argv[at + 1])
del sys.argv[at:at + 2]
+HOST = '127.0.0.1'
+if '--host' in sys.argv:
+ at = sys.argv.index('--host')
+ HOST = sys.argv[at + 1]
+ del sys.argv[at:at + 2]
BUILD = os.path.abspath(sys.argv[1])
DISC = os.path.abspath(sys.argv[2])
PORT = int(sys.argv[3]) if len(sys.argv) > 3 else 8620
@@ -110,5 +115,5 @@ class Handler(http.server.BaseHTTPRequestHandler):
pass
-print('serving %s and %s on http://127.0.0.1:%d/' % (BUILD, DISC, PORT))
-http.server.ThreadingHTTPServer(('127.0.0.1', PORT), Handler).serve_forever()
+print('serving %s and %s on http://%s:%d/' % (BUILD, DISC, HOST, PORT))
+http.server.ThreadingHTTPServer((HOST, PORT), Handler).serve_forever()