Add apidocs endpoint. Closes #1

This commit is contained in:
Ian Renton
2025-09-28 21:51:13 +01:00
parent b03650eb80
commit e66b061155
2 changed files with 19 additions and 0 deletions

View File

@@ -28,6 +28,7 @@ class WebServer:
bottle.get("/api/spots")(self.serve_api_spots)
bottle.get("/api/status")(self.serve_api_status)
bottle.get("/")(self.serve_index)
bottle.get("/apidocs")(self.serve_apidocs)
bottle.get("/<filepath:path>")(self.serve_static_file)
# Start the web server
@@ -62,6 +63,13 @@ class WebServer:
self.status = "OK"
return bottle.static_file("index.html", root="webassets")
# Serve the API docs page. This would be accessible as /apidocs/index.html but we need this workaround to make it
# available as /apidocs
def serve_apidocs(self):
self.last_page_access_time = datetime.now(pytz.UTC)
self.status = "OK"
return bottle.static_file("index.html", root="webassets/apidocs")
# Serve general static files from "webassets" directory
def serve_static_file(self, filepath):
return bottle.static_file(filepath, root="webassets")