phewap icon indicating copy to clipboard operation
phewap copied to clipboard

Error caused by the server file

Open ebolisa opened this issue 1 year ago • 1 comments

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.

ebolisa avatar Apr 18 '24 16:04 ebolisa

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

simonprickett avatar Apr 20 '24 11:04 simonprickett