From 1abe518cf8c41c27fa3d14a321fe34c577524ff8 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Thu, 25 Aug 2022 23:28:09 +0200 Subject: [PATCH] Mention local web server for testing web editor in Compiling/Exporting for the Web --- .../compiling/compiling_for_web.rst | 23 ++++++++++++++ tutorials/export/exporting_for_web.rst | 31 +++++++++++++++++-- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/contributing/development/compiling/compiling_for_web.rst b/contributing/development/compiling/compiling_for_web.rst index 0171a3c60..09c6601bb 100644 --- a/contributing/development/compiling/compiling_for_web.rst +++ b/contributing/development/compiling/compiling_for_web.rst @@ -98,3 +98,26 @@ zip content to your web server and visit it with your browser to use the editor. Refer to the :ref:`export page ` for the web server requirements. + +.. tip:: + + The Godot repository includes a + `Python script to host a local web server `__. + This can be used to test the web editor locally. + + After compiling the editor, extract the ZIP archive that was created in the + ``bin/`` folder, then run the following command in the Godot repository + root: + + :: + + # You may need to replace `python` with `python3` on some platforms. + python platform/web/serve.py + + This will serve the contents of the ``bin/`` folder and open the default web + browser automatically. In the page that opens, access ``godot.tools.html`` + and you should be able to test the web editor this way. + + Note that for production use cases, this Python-based web server should not + be used. Instead, you should use an established web server such as Apache or + nginx. diff --git a/tutorials/export/exporting_for_web.rst b/tutorials/export/exporting_for_web.rst index 6a43c5cbf..1742cd517 100644 --- a/tutorials/export/exporting_for_web.rst +++ b/tutorials/export/exporting_for_web.rst @@ -265,6 +265,32 @@ of its original size with gzip compression. **Hosts that don't provide on-the-fly compression:** itch.io, GitLab Pages (`supports manual gzip precompression `__) +.. tip:: + + The Godot repository includes a + `Python script to host a local web server `__. + This script is intended for testing the web editor, but it can also be used to test exported projects. + + Save the linked script to a file called ``serve.py``, move this file to the + folder containing the exported project's ``index.html``, then run the + following command in a command prompt within the same folder: + + :: + + # You may need to replace `python` with `python3` on some platforms. + python serve.py --root . + + On Windows, you can open a command prompt in the current folder by holding + :kbd:`Shift` and right-clicking on empty space in Windows Explorer, then + choosing **Open PowerShell window here**. + + This will serve the contents of the current folder and open the default web + browser automatically. + + Note that for production use cases, this Python-based web server should not + be used. Instead, you should use an established web server such as Apache or + nginx. + .. _doc_javascript_eval: Calling JavaScript from script @@ -283,7 +309,7 @@ languages integrated into Godot. JavaScriptBridge.eval("alert('Calling JavaScript per GDScript!');") .. code-tab:: csharp - + private void MyFunc() { JavaScriptBridge.Eval("alert('Calling JavaScript per C#!');") @@ -332,7 +358,7 @@ platforms other than HTML5, calling ``JavaScriptBridge.eval`` will also return print("The JavaScriptBridge singleton is NOT available") .. code-tab:: csharp - + private void MyFunc3() { if (OS.HasFeature("web")) @@ -368,4 +394,3 @@ defaulting to ``false`` to prevent polluting the global namespace: // thus adding a new JavaScript global variable `SomeGlobal` JavaScriptBridge.Eval("var SomeGlobal = {};", true); } -