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:
@@ -44,7 +44,7 @@ class WebServer:
|
||||
def serve_api_spots(self):
|
||||
self.last_api_access_time = datetime.now(pytz.UTC)
|
||||
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'
|
||||
return spots_json
|
||||
|
||||
@@ -66,7 +66,16 @@ class WebServer:
|
||||
def serve_static_file(self, filepath):
|
||||
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
|
||||
Reference in New Issue
Block a user