mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-10-27 08:49:27 +00:00
Add apidocs endpoint. Closes #1
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user