我有一个字典,它将一个键映射到多个值,我想将dict作为json文件发送给用户下载。在
@app.route('/test', methods=['GET','POST'])
def test():
data=dict()
foods=['burger','hotdog']
foods2=['fries','chips']
data['John']=foods
data['Ken']=foods2
nutrition=jsonify(data)
return Response(nutrition,
mimetype='application/json',
headers={'Content-Disposition':'attachment;filename=nutrition.json'})
遵循similar post的解决方案,但是我得到一个错误:
TypeError: 'Response' object is not iterable
我也尝试过将data
作为参数发送给Response
,但没有成功。有人能解释一下我做错了什么吗。在
jsonify
为您创建一个Response
对象,因此不应将其传递给Response
构造函数。在相关问题 更多 >
编程相关推荐