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 的错误

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-23
  • 2021-07-20
  • 2021-12-17
  • 2021-11-13
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-05
  • 2021-09-29
相关资源
相似解决方案