diff --git a/taipy/gui/_default_config.py b/taipy/gui/_default_config.py index eb80a4145..7cbc6f20a 100644 --- a/taipy/gui/_default_config.py +++ b/taipy/gui/_default_config.py @@ -46,7 +46,7 @@ "change_delay": None, "chart_dark_template": None, "base_url": "/", - "client_url": "http://127.0.0.1:5000", + "client_url": "http://localhost:{port}", "dark_mode": True, "dark_theme": None, "debug": False, diff --git a/taipy/gui/gui.py b/taipy/gui/gui.py index 1b94d69bf..623b665fe 100644 --- a/taipy/gui/gui.py +++ b/taipy/gui/gui.py @@ -2412,6 +2412,9 @@ def get_flask_app(self) -> Flask: return t.cast(Flask, self._server.get_flask()) raise RuntimeError("get_flask_app() cannot be invoked before run() has been called.") + def _get_port(self) -> int: + return self._server.get_port() + def _set_frame(self, frame: t.Optional[FrameType]): if not isinstance(frame, FrameType): # pragma: no cover raise RuntimeError("frame must be a FrameType where Gui can collect the local variables.") @@ -2777,6 +2780,7 @@ def run( return self._server.run( host=app_config.get("host"), port=app_config.get("port"), + client_url=app_config.get("client_url"), debug=app_config.get("debug"), use_reloader=app_config.get("use_reloader"), flask_log=app_config.get("flask_log"), diff --git a/taipy/gui/server.py b/taipy/gui/server.py index dfada6091..c4d823b66 100644 --- a/taipy/gui/server.py +++ b/taipy/gui/server.py @@ -246,6 +246,9 @@ def _direct_render_json(self, data): def get_flask(self): return self._flask + def get_port(self): + return self._port + def test_client(self): return t.cast(Flask, self._flask).test_client() @@ -286,6 +289,7 @@ def run( self, host, port, + client_url, debug, use_reloader, flask_log, @@ -299,6 +303,7 @@ def run( if port == "auto": port = self._get_random_port(port_auto_ranges) self._port = port + client_url = client_url.format(port=port) if _is_in_notebook() and notebook_proxy: # pragma: no cover from .utils.proxy import NotebookProxy @@ -320,6 +325,7 @@ def run( _TaipyLogger._get_logger().info(f" * Server starting on http://{host_value}:{port}") else: _TaipyLogger._get_logger().info(f" * Server reloaded on http://{host_value}:{port}") + _TaipyLogger._get_logger().info(f" * Application is accessible at {client_url}") if not is_running_from_reloader() and self._gui._get_config("run_browser", False): webbrowser.open(f"http://{host_value}{f':{port}' if port else ''}", new=2) if _is_in_notebook() or run_in_thread: