picoweb icon indicating copy to clipboard operation
picoweb copied to clipboard

TypeError("'NoneType' object isn't iterable",)

Open nasirxo opened this issue 2 years ago • 1 comments

ERROR:picoweb:30.000 <HTTPRequest object at 3fffd830> <Stream object at 3fffd4a0> TypeError("'NoneType' object isn't iterable",) Traceback (most recent call last): File "/lib/picoweb/init.py", line 206, in _handle TypeError: 'NoneType' object isn't iterable {'ir': 'S'}

here is my code `import picoweb

def qs_parse(qs): parameters = {} ampersandSplit = qs.split("&") for element in ampersandSplit: equalSplit = element.split("=") parameters[equalSplit[0]] = equalSplit[1] return parameters

app = picoweb.WebApp(name)

@app.route("/move") def index(req, resp): try: cmd = {x[0] : x[1] for x in [x.split("=") for x in req.qs[1:].split("&") ]} print(cmd) ''' if cmd == 'F': robot.forward() if cmd == 'B': robot.backward() if cmd == 'L': robot.turnleft() if cmd == 'R': robot.turnright() if cmd == 'S': robot.stop() ''' except: pass

@app.route("/action") def index(req, resp): try: cmd = qs_parse(req.qs)['type'] if cmd == '1': robot.beep(20) except: pass

import ulogging as logging logging.basicConfig(level=logging.INFO)

app.run(host='0.0.0.0', port=80)

`

nasirxo avatar Jan 09 '22 08:01 nasirxo

It's hard to read without indentation...

I think you need at least one 'yield' or 'yield from' in the handler functions (index(req, resp)) to make them a generator.

Additional: you used the function name 'index' twice

JK-de avatar Jul 17 '22 19:07 JK-de