Fix routing to allow /index to map to index method

Commit 01b3a27 · patx · 2025-06-03T19:59:47-04:00

Changeset
01b3a27a2538bafe7d99cf353e84beb5731c461e
Parents
3f634764efaea31d7710dff749341e634c7036b9

View source at this commit

Fix routing to allow /index to map to index method

Modified _asgi_app_http to prevent 404 errors for /index by adding a check for path != "index" in the index handler logic. This ensures both / and /index are correctly handled by the index method, aligning with standard web framework conventions.

Comments

No comments yet.

Log in to comment

Diff

diff --git a/MicroPie.py b/MicroPie.py
index dfc2c31..9b07567 100644
--- a/MicroPie.py
+++ b/MicroPie.py
@@ -327,7 +327,7 @@ class App:
                     return
                 func_args.append(param_value)
 
-            if handler == getattr(self, "index", None) and not func_args and path:
+            if handler == getattr(self, "index", None) and not func_args and path and path != "index":
                 await self._send_response(send, 404, "404 Not Found")
                 return