Skip to content

Commit

Permalink
Merge pull request #3130 from plotly/fix-run-params
Browse files Browse the repository at this point in the history
Fix run host/port default arguments
  • Loading branch information
T4rk1n authored Jan 23, 2025
2 parents 9140d3a + 094087f commit 7c03187
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions dash/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -2005,25 +2005,26 @@ def delete_resource(resources):
# pylint: disable=protected-access
delete_resource(self.css._resources._resources)

# pylint: disable=too-many-branches
def run(
self,
host="127.0.0.1",
port="8050",
proxy=None,
debug=None,
host: Optional[str] = None,
port: Optional[Union[str, int]] = None,
proxy: Optional[str] = None,
debug: Optional[bool] = None,
jupyter_mode: Optional[JupyterDisplayMode] = None,
jupyter_width="100%",
jupyter_height=650,
jupyter_server_url=None,
dev_tools_ui=None,
dev_tools_props_check=None,
dev_tools_serve_dev_bundles=None,
dev_tools_hot_reload=None,
dev_tools_hot_reload_interval=None,
dev_tools_hot_reload_watch_interval=None,
dev_tools_hot_reload_max_retry=None,
dev_tools_silence_routes_logging=None,
dev_tools_prune_errors=None,
jupyter_width: str = "100%",
jupyter_height: int = 650,
jupyter_server_url: Optional[str] = None,
dev_tools_ui: Optional[bool] = None,
dev_tools_props_check: Optional[bool] = None,
dev_tools_serve_dev_bundles: Optional[bool] = None,
dev_tools_hot_reload: Optional[bool] = None,
dev_tools_hot_reload_interval: Optional[int] = None,
dev_tools_hot_reload_watch_interval: Optional[int] = None,
dev_tools_hot_reload_max_retry: Optional[int] = None,
dev_tools_silence_routes_logging: Optional[bool] = None,
dev_tools_prune_errors: Optional[bool] = None,
**flask_run_options,
):
"""Start the flask server in local mode, you should not run this on a
Expand All @@ -2032,11 +2033,11 @@ def run(
If a parameter can be set by an environment variable, that is listed
too. Values provided here take precedence over environment variables.
:param host: Host IP used to serve the application
:param host: Host IP used to serve the application, default to "127.0.0.1"
env: ``HOST``
:type host: string
:param port: Port used to serve the application
:param port: Port used to serve the application, default to "8050"
env: ``PORT``
:type port: int
Expand Down Expand Up @@ -2137,8 +2138,14 @@ def run(

# Evaluate the env variables at runtime

host = host or os.getenv("HOST")
port = port or os.getenv("PORT")
if "CONDA_PREFIX" in os.environ:
# Some conda systems has issue with setting the host environment
# to an invalid hostname.
# Related issue: https://github.com/plotly/dash/issues/3069
host = host or "127.0.0.1"
else:
host = host or os.getenv("HOST", "127.0.0.1")
port = port or os.getenv("PORT", "8050")
proxy = proxy or os.getenv("DASH_PROXY")

# Verify port value
Expand Down

0 comments on commit 7c03187

Please sign in to comment.