mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
[Web] Add the "serve" and "run" scons targets.
You can now run the test HTTP server by calling: scons p=web serve If you also wish to run the browser, call instead: scons p=web run The default listen port is 8060, but can be overriden via the env variable GODOT_WEB_TEST_PORT which must be a valid integer.
This commit is contained in:
parent
ea47e03b36
commit
a06602363c
2 changed files with 26 additions and 9 deletions
|
@ -24,6 +24,17 @@ def shell_open(url):
|
|||
subprocess.call([opener, url])
|
||||
|
||||
|
||||
def serve(root, port, run_browser):
|
||||
os.chdir(root)
|
||||
|
||||
if run_browser:
|
||||
# Open the served page in the user's default browser.
|
||||
print("Opening the served URL in the default browser (use `--no-browser` or `-n` to disable this).")
|
||||
shell_open(f"http://127.0.0.1:{port}")
|
||||
|
||||
test(CORSRequestHandler, HTTPServer, port=port)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-p", "--port", help="port to listen on", default=8060, type=int)
|
||||
|
@ -41,12 +52,4 @@ if __name__ == "__main__":
|
|||
# so that the script can be run from any location.
|
||||
os.chdir(Path(__file__).resolve().parent)
|
||||
|
||||
if args.root:
|
||||
os.chdir(args.root)
|
||||
|
||||
if args.browser:
|
||||
# Open the served page in the user's default browser.
|
||||
print("Opening the served URL in the default browser (use `--no-browser` or `-n` to disable this).")
|
||||
shell_open(f"http://127.0.0.1:{args.port}")
|
||||
|
||||
test(CORSRequestHandler, HTTPServer, port=args.port)
|
||||
serve(args.root, args.port, args.browser)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue