MicroWebSrv2 icon indicating copy to clipboard operation
MicroWebSrv2 copied to clipboard

Route Arguments Not Working

Open jvigliottaa opened this issue 5 years ago • 4 comments

I am running into an issue when trying to use Route Arguments. I defined the web route as:

@WebRoute(GET, '/Key/<key_val>/Data/')

but when a GET request such as:

GET /Key/DATA_UPLOAD_METHOD/Data/LoRa

is sent the program does not recognize it as a valid route. and I get:

MWS2-DEBUG> From 192.168.4.2:51137 GET /Key/DATA_UPLOAD_METHOD/Data/LoRa >> [307] Temporary Redirect

jvigliottaa avatar Apr 28 '20 16:04 jvigliottaa

Your route ends with Data/ in the declaration, but with Data/LoRa in your request.

Try to change the webroute to @webroute(GET, '/Key/<key_val>/Data/LoRa') or to @webroute(GET, '/Key/<key_val>/Data/<page_name>') or change your request.

YveIce avatar May 05 '20 22:05 YveIce

I must of miss copied but my route is: @WebRoute(GET, '/Key/<key_val>/Data/<data>')

It does not recognize it with the request: GET /Key/DATA_UPLOAD_METHOD/Data/LoRa

jvigliottaa avatar May 05 '20 22:05 jvigliottaa

Ah ok. Check if this change fix it for you: in file "webRoute.py" on line 57

                    regex += '/([\\w.]*)'
                else :
                    regex += '/' + part

remove the [ and ] like so:

                    regex += '/(\\w.*)'
                else :
                    regex += '/' + part

It seems, there is a bug in lib re (RegEx) on micropython(ESP32, others not tested). Maybe somebody knows more, but this is the dirty fix, that works for me right now.

YveIce avatar May 06 '20 00:05 YveIce

This fixed for me. Thanks

zeeshanyshaikh avatar Aug 29 '20 16:08 zeeshanyshaikh