From 1b0494c45a5b8ac8bbea621f14688c95ecadf8ee Mon Sep 17 00:00:00 2001 From: W1CDN Date: Sat, 26 Aug 2023 16:47:23 -0500 Subject: [PATCH] Very rough workaround for relative API urls. --- api_app.py | 9 ++++++--- config_default.ini | 3 +++ requirements.txt | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/api_app.py b/api_app.py index 8329603..f9adff1 100644 --- a/api_app.py +++ b/api_app.py @@ -91,7 +91,9 @@ def index(): # Get list of recent packets using API # TODO use relative path - frames = json.loads(requests.get("https://digi.w1cdn.net/aprs_api/packets").text)['data'] + #frames = json.loads(requests.get(url_for("packets", _external=True)).text)['data'] + #frames = json.loads(requests.get("https://digi.w1cdn.net/aprs_api/packets").text)['data'] + frames = json.loads(requests.get(config['Settings']['base_url']+"/packets").text)['data'] for frame in frames: if frame['created'] != None: frame['time_ago'] = timeago.format(frame['created_unix'], datetime.datetime.now()) @@ -101,7 +103,9 @@ def index(): #stations = select_all_stations(get_db_connection()) #print(url_for("static", filename="test.txt", _external=True)) # this should work: stations = json.loads(requests.get(url_for("stations", _external=True)).text)['data'] - stations = json.loads(requests.get("https://digi.w1cdn.net/aprs_api/stations").text)['data'] + #stations = json.loads(requests.get(url_for("stations", _external=True)).text)['data'] + #stations = json.loads(requests.get("https://digi.w1cdn.net/aprs_api/stations").text)['data'] + stations = json.loads(requests.get(config['Settings']['base_url']+"/stations").text)['data'] # Convert unix time to datetime on the fly because I'm lazy right now for station in stations: if station['last_heard_unix'] != None: @@ -148,7 +152,6 @@ class Stations(Resource): # Read config config = read_config() -log_folder = config['Settings']['log_folder'] # Start subprocess to watch KISS connection import subprocess diff --git a/config_default.ini b/config_default.ini index 77cba3d..b729dce 100644 --- a/config_default.ini +++ b/config_default.ini @@ -4,6 +4,9 @@ station_call = W1CDN-1 station_lat = 47.941500 station_lon = -97.027000 +# Base URL for application (no trailing slash) +base_url = https://digi.w1cdn.net/aprs_api + # How long to keep packets (frames) e.g., "2 days", "5 minutes" keep_time = "2 days" diff --git a/requirements.txt b/requirements.txt index 567e8db..4ef0f1d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,4 @@ kiss aprslib sqlite3 json +timeago \ No newline at end of file