Skip to content
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

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

Open
nasirxo opened this issue Jan 9, 2022 · 1 comment
Open

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

nasirxo opened this issue Jan 9, 2022 · 1 comment

Comments

@nasirxo
Copy link

nasirxo commented Jan 9, 2022

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)

`

@JK-de
Copy link

JK-de commented Jul 17, 2022

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

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

No branches or pull requests

2 participants