Version API and add spot_allowed to options call. Closes #35

This commit is contained in:
Ian Renton
2025-10-09 15:35:29 +01:00
parent c66693fc99
commit 277743dac7
5 changed files with 20 additions and 16 deletions

View File

@@ -29,11 +29,11 @@ class WebServer:
self.status = "Starting"
# Routes for API calls
bottle.get("/api/spots")(lambda: self.serve_api(self.get_spot_list_with_filters()))
bottle.get("/api/alerts")(lambda: self.serve_api(self.get_alert_list_with_filters()))
bottle.get("/api/options")(lambda: self.serve_api(self.get_options()))
bottle.get("/api/status")(lambda: self.serve_api(self.status_data))
bottle.post("/api/spot")(lambda: self.accept_spot())
bottle.get("/api/v1/spots")(lambda: self.serve_api(self.get_spot_list_with_filters()))
bottle.get("/api/v1/alerts")(lambda: self.serve_api(self.get_alert_list_with_filters()))
bottle.get("/api/v1/options")(lambda: self.serve_api(self.get_options()))
bottle.get("/api/v1/status")(lambda: self.serve_api(self.status_data))
bottle.post("/api/v1/spot")(lambda: self.accept_spot())
# Routes for templated pages
bottle.get("/")(lambda: self.serve_template('webpage_spots'))
bottle.get("/alerts")(lambda: self.serve_template('webpage_alerts'))
@@ -103,7 +103,6 @@ class WebServer:
spot.icon = "desktop"
spot.infer_missing()
self.spots.add(spot.id, spot, expire=MAX_SPOT_AGE)
print(spot)
response.content_type = 'application/json'
response.set_header('Cache-Control', 'no-store')
@@ -238,7 +237,8 @@ class WebServer:
"alert_sources": list(
map(lambda p: p["name"], filter(lambda p: p["enabled"], self.status_data["alert_providers"]))),
"continents": CONTINENTS,
"max_spot_age": MAX_SPOT_AGE}
"max_spot_age": MAX_SPOT_AGE,
"spot_allowed": ALLOW_SPOTTING}
# If spotting to this server is enabled, "API" is another valid spot source even though it does not come from
# one of our proviers.
if ALLOW_SPOTTING: