Skip to content

Commit 62179e2

Browse files
committed
Allow specifying openlayer server url as env var
1 parent 420ddd2 commit 62179e2

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

openlayer/api.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ def __init__(self, api_key: str):
7373
)
7474

7575
self.api_key = api_key
76+
self.base_url = os.getenv("OPENLAYER_SERVER_URL", OPENLAYER_ENDPOINT).rstrip(
77+
"/"
78+
)
79+
if not self.base_url.endswith("/v1"):
80+
self.base_url += "/v1"
81+
7682
self._headers = {
7783
"Content-Type": "application/json",
7884
"Authorization": f"Bearer {self.api_key}",
@@ -143,7 +149,7 @@ def _api_request(
143149
):
144150
"""Make any HTTP request + error handling."""
145151

146-
url = f"{OPENLAYER_ENDPOINT}/{endpoint}"
152+
url = f"{self.base_url}/{endpoint}"
147153

148154
res = self._http_request(
149155
method=method,

openlayer/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@
2323
)
2424
"""
2525

26-
__version__ = "0.1.0a35"
26+
__version__ = "0.1.0a36"

0 commit comments

Comments
 (0)