Instantiate but disable providers. Closes #16

This commit is contained in:
Ian Renton
2025-10-02 09:38:05 +01:00
parent 9e495a3fae
commit 9640c0e0c1
18 changed files with 134 additions and 132 deletions

View File

@@ -30,7 +30,6 @@ class WebServer:
bottle.get("/api/options")(self.serve_api_options)
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
@@ -69,20 +68,21 @@ class WebServer:
# Serve the home page. This would be accessible as /index.html but we need this workaround to make it available as /
def serve_index(self):
self.last_page_access_time = datetime.now(pytz.UTC)
self.status = "OK"
return bottle.static_file("index.html", root="webassets")
return self.serve_static_file("")
# 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
# Serve general static files from "webassets" directory, along with some extra workarounds to make URLs such as
# "/", "/about" and "/apidocs" work.
def serve_static_file(self, filepath):
return bottle.static_file(filepath, root="webassets")
self.last_page_access_time = datetime.now(pytz.UTC)
self.status = "OK"
if filepath == "":
return bottle.static_file("index.html", root="webassets")
elif filepath == "about":
return bottle.static_file("about.html", root="webassets")
elif filepath == "apidocs":
return bottle.static_file("index.html", root="webassets/apidocs")
else:
return bottle.static_file(filepath, root="webassets")
# Utility method to apply filters to the overall spot list and return only a subset. Enables query parameters in
# the main "spots" GET call. The "query" parameter should be the result of bottle's request.query, and is a MultiDict