Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix run host/port default arguments #3130

Merged
merged 5 commits into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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