Skip to content

Commit 7c03187

Browse files
authored
Merge pull request #3130 from plotly/fix-run-params
Fix run host/port default arguments
2 parents 9140d3a + 094087f commit 7c03187

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

dash/dash.py

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,25 +2005,26 @@ def delete_resource(resources):
20052005
# pylint: disable=protected-access
20062006
delete_resource(self.css._resources._resources)
20072007

2008+
# pylint: disable=too-many-branches
20082009
def run(
20092010
self,
2010-
host="127.0.0.1",
2011-
port="8050",
2012-
proxy=None,
2013-
debug=None,
2011+
host: Optional[str] = None,
2012+
port: Optional[Union[str, int]] = None,
2013+
proxy: Optional[str] = None,
2014+
debug: Optional[bool] = None,
20142015
jupyter_mode: Optional[JupyterDisplayMode] = None,
2015-
jupyter_width="100%",
2016-
jupyter_height=650,
2017-
jupyter_server_url=None,
2018-
dev_tools_ui=None,
2019-
dev_tools_props_check=None,
2020-
dev_tools_serve_dev_bundles=None,
2021-
dev_tools_hot_reload=None,
2022-
dev_tools_hot_reload_interval=None,
2023-
dev_tools_hot_reload_watch_interval=None,
2024-
dev_tools_hot_reload_max_retry=None,
2025-
dev_tools_silence_routes_logging=None,
2026-
dev_tools_prune_errors=None,
2016+
jupyter_width: str = "100%",
2017+
jupyter_height: int = 650,
2018+
jupyter_server_url: Optional[str] = None,
2019+
dev_tools_ui: Optional[bool] = None,
2020+
dev_tools_props_check: Optional[bool] = None,
2021+
dev_tools_serve_dev_bundles: Optional[bool] = None,
2022+
dev_tools_hot_reload: Optional[bool] = None,
2023+
dev_tools_hot_reload_interval: Optional[int] = None,
2024+
dev_tools_hot_reload_watch_interval: Optional[int] = None,
2025+
dev_tools_hot_reload_max_retry: Optional[int] = None,
2026+
dev_tools_silence_routes_logging: Optional[bool] = None,
2027+
dev_tools_prune_errors: Optional[bool] = None,
20272028
**flask_run_options,
20282029
):
20292030
"""Start the flask server in local mode, you should not run this on a
@@ -2032,11 +2033,11 @@ def run(
20322033
If a parameter can be set by an environment variable, that is listed
20332034
too. Values provided here take precedence over environment variables.
20342035
2035-
:param host: Host IP used to serve the application
2036+
:param host: Host IP used to serve the application, default to "127.0.0.1"
20362037
env: ``HOST``
20372038
:type host: string
20382039
2039-
:param port: Port used to serve the application
2040+
:param port: Port used to serve the application, default to "8050"
20402041
env: ``PORT``
20412042
:type port: int
20422043
@@ -2137,8 +2138,14 @@ def run(
21372138

21382139
# Evaluate the env variables at runtime
21392140

2140-
host = host or os.getenv("HOST")
2141-
port = port or os.getenv("PORT")
2141+
if "CONDA_PREFIX" in os.environ:
2142+
# Some conda systems has issue with setting the host environment
2143+
# to an invalid hostname.
2144+
# Related issue: https://github.com/plotly/dash/issues/3069
2145+
host = host or "127.0.0.1"
2146+
else:
2147+
host = host or os.getenv("HOST", "127.0.0.1")
2148+
port = port or os.getenv("PORT", "8050")
21422149
proxy = proxy or os.getenv("DASH_PROXY")
21432150

21442151
# Verify port value

0 commit comments

Comments
 (0)