simonprickett / phewap

Raspberry Pi Pico W Wifi Configuration Example with Pimoroni Phew and MicroPython
MIT License
72 stars 16 forks source link

Error caused by the server file #11

Open ebolisa opened 5 months ago

ebolisa commented 5 months ago

Hi, Thanks for sharing!! I found a minor issue on line 34 in server.py. With my ESP32 it was causing the following error:

Task exception wasn't retrieved
future: <Task> coro= <generator object '_handle_request' at 3ffd82c0>
Traceback (most recent call last):
  File "asyncio/core.py", line 1, in run_until_complete
  File "/lib/phew/server.py", line 241, in _handle_request
  File "/lib/phew/server.py", line 53, in __init__
  File "/lib/phew/server.py", line 34, in _parse_query_string
ValueError: need more than 1 values to unpack

However, it only appeared on the first run and was not halting the task. I fixed it by checking for the "=" char.

def _parse_query_string(query_string):
    result = {}
    for parameter in query_string.split("&"):
        if "=" in parameter:
            key, value = parameter.split("=", 1)
            key = urldecode(key)
            value = urldecode(value)
            result[key] = value
    return result

Thanks again and best regards.

simonprickett commented 4 months ago

Hi there - thanks - this looks like a problem with the base Pimoroni Phew code that I've copied into this repository. I'll check this out and raise an issue with them -- I think I have an ESP32 device somewhere to try it with. https://github.com/pimoroni/phew