how toupload images in flask api code example
Example 1: how to get images on flask page
<img src="{{url_for('static', filename='MD.png')}}">
Example 2: flask rest api upload image
from flask import Flask
from flask_restful import Resource, Api, reqparse
import werkzeug
class UploadAudio(Resource):
def post(self):
parse = reqparse.RequestParser()
parse.add_argument('file', type=werkzeug.datastructures.FileStorage, location='files')
args = parse.parse_args()
audioFile = args['file']
audioFile.save("your_file_name.jpg")