Don't fail if there is only one path segment
diff --git a/server/main.py b/server/main.py
index f21a684..325b76a 100644
--- a/server/main.py
+++ b/server/main.py
@@ -134,7 +134,12 @@
# We are backwards compatible with the old Lua interface URLs
body_type = "form"
# Support URLs of form /api/handler/extra?query
- handler = request.path.split("/")[2]
+ parts = request.path.split("/")
+ if len(parts) < 3:
+ return aiohttp.web.Response(
+ headers=headers, status=404, text="API Endpoint not found!"
+ )
+ handler = parts[2]
# handle test requests
if self.stoppable and handler == 'stop':
self.background_event.set()