Skip to content

NoneType is not iterable (finish_response) #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
speccy88 opened this issue Nov 24, 2021 · 1 comment · Fixed by #13
Closed

NoneType is not iterable (finish_response) #11

speccy88 opened this issue Nov 24, 2021 · 1 comment · Fixed by #13

Comments

@speccy88
Copy link

Can anyone tell me what could cause this error?
Traceback (most recent call last): File "code.py", line 107, in <module> File "adafruit_esp32spi/adafruit_esp32spi_wsgiserver.py", line 106, in update_poll File "adafruit_esp32spi/adafruit_esp32spi_wsgiserver.py", line 122, in finish_response TypeError: 'NoneType' object is not iterable

@mfinkle
Copy link

mfinkle commented Jan 4, 2022

I have run into this kind of error when I forget to add a return to my route handlers. Make sure you add the final line:

@web_app.route("/led_on/<r>/<g>/<b>")
def led_on(request, r, g, b): 
    print("led on!")
    status_light.fill((int(r), int(g), int(b)))
    return ("200 OK", [], [])

Even when you are handling a POST:

@web_app.route("/led_on", ["POST"])
def led_on(request):
    print("led on!")
    r = request.query_params["r"]
    g = request.query_params["g"]
    b = request.query_params["b"]
    status_light.fill((int(r), int(g), int(b)))
    return ("200 OK", [], [])

The third parameter is the response content and it needs to be iterable, like an empty List, or even an empty string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants