flask 基于Werkzeug ..
@moudule.route('/upload', methods=['GET', 'POST']) def upload_file(): global _flask_app if request.method == 'POST': file = request.files['file'] if file and allowed_file(file.filename): filename = secure_filename(file.filename) file.save(os.path.join(_flask_app.config['UPLOAD_FOLDER'], filename)) return json.dumps({'info': '上传完成'}) else: return json.dumps({'info': '文件不存在或者不合法'}) else: return json.dumps({'info': '方法不支持'})
请求处理函数中如果直接 :
return {'info': '方法不支持'}
就会报 TypeError: 'dict' object is not callable 的错误
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ezhong的博客签名-------------------------------------
以上内容来自ezhong的博客园,作者:ezhong
ezhong的博客园: http://www.cnblogs.com/ezhong
感谢您的阅读。感谢您的分享。