summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2021-03-30 16:26:50 +0200
committerDaniel Friesel <derf@finalrewind.org>2021-03-30 16:26:50 +0200
commitb2a996bdfa7b589ee1007b5dfed04a5c581d22d9 (patch)
treecacd3246891a850e659cda0f066094461aa53d3d
parentd8c1ab32a1f020b52ab751b1d166c2878ad0e1c2 (diff)
support custom transport.rest instances
-rwxr-xr-xbin/lookup-server6
1 files changed, 4 insertions, 2 deletions
diff --git a/bin/lookup-server b/bin/lookup-server
index 2966995..e746e48 100755
--- a/bin/lookup-server
+++ b/bin/lookup-server
@@ -25,6 +25,8 @@ conn = psycopg2.connect(
host=os.getenv("GEOLOOKUP_DBHOST", "localhost"),
)
+db_rest_api = os.getenv("GEOLOOKUP_DB_REST_API", "https://v5.db.transport.rest")
+
conn.autocommit = True
conn.set_session(readonly=True)
@@ -120,7 +122,7 @@ def set_coarse_location(train, latlon):
async def set_location(train):
trip_id = train["tripId"]
line = train["line"]["name"]
- url = f"https://v5.db.transport.rest/trips/{trip_id}?lineName={line}&polyline=true"
+ url = f"{db_rest_api}/trips/{trip_id}?lineName={line}&polyline=true"
return
logging.debug(f"Requesting polyline for {line}: {url}")
async with aiohttp.ClientSession() as session:
@@ -191,7 +193,7 @@ async def handle_search(request):
logging.debug(f"Requesting arrivals at {eva}")
async with aiohttp.ClientSession() as session:
async with session.get(
- f"https://v5.db.transport.rest/stops/{eva}/arrivals?results=40&duration=120&stopovers=true&bus=false&subway=false&tram=false"
+ f"{db_rest_api}/stops/{eva}/arrivals?results=40&duration=120&stopovers=true&bus=false&subway=false&tram=false"
) as response:
content = await response.text()
content = json.loads(content)