Very rough workaround for relative API urls.

This commit is contained in:
W1CDN 2023-08-26 16:47:23 -05:00
parent f694e65c2a
commit 1b0494c45a
3 changed files with 10 additions and 3 deletions

View File

@ -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

View File

@ -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"

View File

@ -6,3 +6,4 @@ kiss
aprslib
sqlite3
json
timeago