code

from flask import Flask
from flask_restful import Api, Resource, reqparse
import  werkzeug

app = Flask(__name__)
api = Api(app)

class Uploads(Resource):
    def post(self):
        parser = reqparse.RequestParser()
        parser.add_argument('file', type=werkzeug.FileStorage,location='files', action='append')
        args = parser.parse_args()
        files = args.file 
        for file in files:
            file.save('test.jpeg')
        return {'msg': '文件上传成功!'}

api.add_resource(Uploads, '/upload')


if __name__ == '__main__':
  app.run(debug=True)

 
上传图片:
flask 上传图片
 
 
 
 
 

 

 

 

 

 

 

 

 

 

相关文章:

  • 2022-12-23
  • 2022-01-01
  • 2021-08-12
  • 2022-12-23
  • 2021-08-20
  • 2022-01-08
  • 2022-03-03
  • 2022-12-23
猜你喜欢
  • 2021-05-05
  • 2021-06-11
  • 2022-01-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案