diff --git a/docs/userman/advanced_features/configuration/gui-config.md b/docs/userman/advanced_features/configuration/gui-config.md index b2bc85696..0d0fa10e6 100644 --- a/docs/userman/advanced_features/configuration/gui-config.md +++ b/docs/userman/advanced_features/configuration/gui-config.md @@ -205,7 +205,37 @@ Here is the list of the configuration parameters you can use in `Gui.run()^` or `Gui.get_flask_app()^` so it is served by the target web server. - *base_url* (str or None, default: "/"): a string used as a prefix to the path part of the exposed URL, so one can deploy a Taipy GUI application in a path - different from the root of the web site. + different from the root of the web site.
+ If you need to expose the application under the prefix "*my_application*", you can set this + path to the *base_url* paramameter of the `Gui.run()^` method: + ```python + Gui(pages=...).run(base_url="/my_application") + ``` + The application prefix must also be handled at the web server level, to properly proxy the + requests.
+ Here is an example using [**ngnix**](https://nginx.org/): the server is listening to port 8080 + and redirecting the traffic to the Taipy application, locally on port 5000. Here is what could + be indicated in the web server configuration file: + ``` + server { + listen 8080; + + location /my_application { + rewrite /my_application/(.*) /$1 break; + rewrite /my_application / break; + proxy_pass http://172.17.0.1:5000; + } + + location /my_application/socket.io { + proxy_http_version 1.1; + proxy_buffering off; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + proxy_pass http://172.17.0.1:5000/socket.io; + } + } + ``` + Note that web socket redirection needs to be setup. - *allow_unsafe_werkzeug* (bool, default: False): hides some [Flask-SocketIO](https://pypi.org/project/Flask-SocketIO/) runtime errors in some debugging scenarios. This is set to True when [*debug*](#p-debug) is set to True. diff --git a/docs/userman/gui/pages/index.md b/docs/userman/gui/pages/index.md index 96276bce6..b6b9aab1e 100644 --- a/docs/userman/gui/pages/index.md +++ b/docs/userman/gui/pages/index.md @@ -211,11 +211,13 @@ associates a page with its name: # gui.run() ``` -You could have also used the `(Gui.)add_page()` function. +You could have also used the `(Gui.)add_page()^` function for each page. - -In this situation, to see the pages in your browser, the address you will use -will be *localhost:5000/home* or *localhost:5000/about*. Learn how to natigate between pages [here](../pages/navigate/index.md). +In this situation, to see the pages in your browser, the address you will use will be +*localhost:5000/home* or *localhost:5000/about*. Learn how to navigate between pages +[here](../pages/navigate/index.md).
+If you point the browser to the root of the server (*localhost:5000/*) then it will be redirected to +the first added page. In our situation, the *home* page at *localhost:5000/home*. Note that if pages are created in different modules, the variables that they can bind to visual elements may have a scope limited to their origin module. See @@ -223,38 +225,57 @@ to visual elements may have a scope limited to their origin module. See ## Root page -The *Root* page is the page located at `"/"` (or the value of the -[*base_url*](../../advanced_features/configuration/gui-config.md#p-base_url) configuration setting). -The content of the page will be shown at the top of every page of your application. +The *Root* page is the page located at `"/"`. + +You may choose to expose you application pages to another top directory. To do this, you must +prefix each page name with the directory you wish to expose: +```python +pages = { + "/": root_md, + "my_application/home": home_md, + "my_application/about": about_md +} +``` + +When opening a browser on the page located at *localhost:5000/*, it will be redirected to the +first declared page, at *localhost:5000/my_application/home*. + +The content of the root page will be displayed at the top of every page of your application. + +If you want to expose your application at a given root directory in a production environment, you +may want to set the value of the +[*base_url*](../../advanced_features/configuration/gui-config.md#p-base_url) configuration setting. +Please refer to the documentation for this setting for more information. ## Application header and footer Your application may also need to hold a footer on all the pages it uses.
-You can use the pseudo-control `<|content|>` to achieve the expected result: this +You can use the pseudo-control `content` to achieve the expected result: this visual element is not *really* a control: It is a placeholder for page content, used in the root page of your application, and is replaced by the target page content when the application runs. -!!! example +!!! example "Adding a page footer" ```python from taipy import Gui - if __name__ == "__main__": - root_md=""" + root_md=""" # Multi-page application <|content|> This application was created with [Taipy](https://www.taipy.io/). - """ - home_md="## Home" - about_md="## About" + """ + home_md="## Home" + about_md="## About" - pages = { - "/": root_md, - "home": home_md, - "about": about_md - } + pages = { + "/": root_md, + "home": home_md, + "about": about_md + } + + if __name__ == "__main__": Gui(pages=pages).run() ```