patx/micropie
Fix routing to allow /index to map to index method
Commit 01b3a27 · patx · 2025-06-03T19:59:47-04:00
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.
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