Skip to content

Commit f40ae12

Browse files
add options to is_dev_env check
1 parent f1b81e8 commit f40ae12

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

mp_api/client/_server_utils.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from mp_api.client.core.utils import validate_api_key
1515

1616
if TYPE_CHECKING:
17+
from collections.abc import Sequence
1718
from typing import Any
1819

1920

@@ -40,9 +41,15 @@ def get_request_headers() -> dict[str, Any]:
4041
return request.headers if has_request_context() else {}
4142

4243

43-
def is_dev_env() -> bool:
44+
def is_dev_env(
45+
localhosts : Sequence[str] = ("localhost:", "127.0.0.1:", "0.0.0.0:")
46+
) -> bool:
4447
"""Determine if current env is local/developmental or production.
4548
49+
Args:
50+
localhosts (Sequence of str) : A set of host prefixes for checking
51+
if the current environment is locally deployed.
52+
4653
Returns:
4754
bool: True if the environment is locally hosted.
4855
"""
@@ -51,7 +58,7 @@ def is_dev_env() -> bool:
5158
if not has_request_context()
5259
else get_request_headers()
5360
.get("Host", "")
54-
.startswith(("localhost:", "127.0.0.1:", "0.0.0.0:"))
61+
.startswith(localhosts)
5562
)
5663

5764

0 commit comments

Comments
 (0)