Starting implementation of posting spots #2

This commit is contained in:
Ian Renton
2025-10-03 22:06:03 +01:00
parent 7af7475c5a
commit df5c01bb62
2 changed files with 51 additions and 7 deletions

View File

@@ -30,6 +30,7 @@ class WebServer:
bottle.get("/api/spots")(lambda: self.serve_api(self.get_spot_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())
# Routes for templated pages
bottle.get("/")(lambda: self.serve_template('webpage_home'))
bottle.get("/about")(lambda: self.serve_template('webpage_about'))
@@ -55,6 +56,17 @@ class WebServer:
response.set_header('Cache-Control', 'no-store')
return json.dumps(data, default=serialize_everything)
# Accept a spot
def accept_spot(self):
self.last_api_access_time = datetime.now(pytz.UTC)
self.status = "OK"
print(bottle.request.forms.spot)
response.content_type = 'application/json'
response.set_header('Cache-Control', 'no-store')
return json.dumps("OK", default=serialize_everything)
# Serve a templated page
def serve_template(self, template_name):
self.last_page_access_time = datetime.now(pytz.UTC)