From e66b0611552f1c5cadcd97555ecadcb44e790bbd Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Sun, 28 Sep 2025 21:51:13 +0100 Subject: [PATCH] Add apidocs endpoint. Closes #1 --- server/webserver.py | 8 ++++++++ webassets/apidocs/index.html | 11 +++++++++++ 2 files changed, 19 insertions(+) create mode 100644 webassets/apidocs/index.html diff --git a/server/webserver.py b/server/webserver.py index fd35d2c..a0b77cf 100644 --- a/server/webserver.py +++ b/server/webserver.py @@ -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("/")(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") diff --git a/webassets/apidocs/index.html b/webassets/apidocs/index.html new file mode 100644 index 0000000..d0d6d87 --- /dev/null +++ b/webassets/apidocs/index.html @@ -0,0 +1,11 @@ + + + + + API Documentation + + + + + + \ No newline at end of file