The problem is that your endpoint is returning a list. Flask only likes certain return types. The two that are probably the most common are
- a
Response
object
- a
str
(along with unicode
in Python 2.x)
You can also return any callable, such as a function.
If you want to return a list of devices you have a couple of options. You can return the list as a string
@server.route('/devices')
def status():
return ','.join(app.statusOfDevices())
or you if you want to be able to treat each device as a separate value, you can return a JSON response
from flask.json import jsonify
@server.route('/devices')
def status():
return jsonify({'devices': app.statusOfDevices()})
# an alternative with a complete Response object
# return flask.Response(jsonify({'devices': app.statusOfDevices()}), mimetype='application/json')
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…