mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-10-27 08:49:27 +00:00
Starting to implement queries for the JSON endpoint
This commit is contained in:
@@ -5,7 +5,7 @@ from providers.http_provider import HTTPProvider
|
|||||||
|
|
||||||
|
|
||||||
# Provider for Worldwide Bunkers on the Air
|
# Provider for Worldwide Bunkers on the Air
|
||||||
# todo switch to event source API as per Steve change to Field Spotter
|
# todo switch to event source API as per Steve change to Field Spotter, if Python supports it
|
||||||
class WWBOTA(HTTPProvider):
|
class WWBOTA(HTTPProvider):
|
||||||
POLL_INTERVAL_SEC = 120
|
POLL_INTERVAL_SEC = 120
|
||||||
SPOTS_URL = "https://api.wwbota.org/spots/"
|
SPOTS_URL = "https://api.wwbota.org/spots/"
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class WebServer:
|
|||||||
def serve_api_spots(self):
|
def serve_api_spots(self):
|
||||||
self.last_api_access_time = datetime.now(pytz.UTC)
|
self.last_api_access_time = datetime.now(pytz.UTC)
|
||||||
self.status = "OK"
|
self.status = "OK"
|
||||||
spots_json = json.dumps(self.spot_list, default=serialize_everything)
|
spots_json = json.dumps(self.get_spot_list_with_filters(bottle.request.query), default=serialize_everything)
|
||||||
response.content_type = 'application/json'
|
response.content_type = 'application/json'
|
||||||
return spots_json
|
return spots_json
|
||||||
|
|
||||||
@@ -66,7 +66,16 @@ class WebServer:
|
|||||||
def serve_static_file(self, filepath):
|
def serve_static_file(self, filepath):
|
||||||
return bottle.static_file(filepath, root="webassets")
|
return bottle.static_file(filepath, root="webassets")
|
||||||
|
|
||||||
|
# Utility method to apply filters to the overall spot list and return only a subset. Enables query parameters in
|
||||||
|
# the main "spots" GET call. The "query" parameter should be the result of bottle's request.query, and is a MultiDict
|
||||||
|
def get_spot_list_with_filters(self, query):
|
||||||
|
spot_subset = self.spot_list[:]
|
||||||
|
for k in query.keys():
|
||||||
|
print(k + ": " + query.get(k))
|
||||||
|
return spot_subset
|
||||||
|
|
||||||
# Todo spot API arguments e.g. "since" based on received_time of spots, sources, sigs, dx cont, dxcc, de cont, band, mode, filter out qrt, filter pre-qsy, sort order, list of fields
|
|
||||||
# Todo serve status API
|
|
||||||
|
|
||||||
|
# Todo serve Server-Sent Events to frontend - see https://medium.com/@tdenton8772/streaming-api-design-using-python-and-javascript-1b0ce8adb703
|
||||||
# Todo serve apidocs
|
# Todo serve apidocs
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
// TODO get all data into JS
|
// TODO get all data into JS on first load
|
||||||
|
// TODO subscribe to SSE to get updates, merge with local data, sort, refresh display
|
||||||
|
// TODO cap at a sensible number of lines in the table, throw away other data, make the number configurable
|
||||||
// TODO populate table more nicely
|
// TODO populate table more nicely
|
||||||
// TODO track last received time and use API since call, merge and sort local data, refresh display
|
|
||||||
// TODO filtering (applied locally)
|
// TODO filtering (applied locally)
|
||||||
// TODO look and feel
|
// TODO look and feel
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user