Skip to content

Error caused by the server file #11

@ebolisa

Description

@ebolisa

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions