jczic / MicroWebSrv2

The last Micro Web Server for IoTs (MicroPython) or large servers (CPython), that supports WebSockets, routes, template engine and with really optimized architecture (mem allocations, async I/Os). Ready for ESP32, STM32 on Pyboard, Pycom's chipsets (WiPy, LoPy, ...). Robust, efficient and documented!
https://github.com/jczic/MicroWebSrv2
MIT License
659 stars 97 forks source link

Route not working? #91

Open concentrateddon opened 1 year ago

concentrateddon commented 1 year ago

I've defined the following:

@WebRoute(GET, '/writedevice/<mac>/<target>')
def handleWriteDevice(microWebSrv2, request, args) :
    print()
    print('Writing device',args['mac'],'to',args['target'])
    WriteDevice(args['mac'],args['target'])
    request.Response.ReturnOk()

Upon running the project, I can see that the route is registered:

 + [@WebRoute] GET /writedevice/<mac>/<target>

There are no other routes using /writedevice:

Creating WWW routes
 + [@WebRoute] GET /
 + [@WebRoute] GET /getdevicelist
 + [@WebRoute] GET /getschedule
 + [@WebRoute] GET /addschedule/<mac>/<abovebelow>/<light>/<target>
 + [@WebRoute] GET /deleteschedule/<id>
 + [@WebRoute] GET /testlight
 + [@WebRoute] GET /writedevice/<mac>/<target>

However, an incoming request isn't picked up:

WWW: From 192.168.68.81:53110 GET /writedevice/34ab958f6ed40004/100 >> [307] Temporary Redirect

Any suggestions? I feel like I must be doing something wrong with the arguments bit of it, but I can't figure it out.