我想通过POSTMAN的POST方法传递图片,但在请求文件行中得到了None类型的响应request.files['image']。
我尝试了许多不同的方法,但是我无法解决这个问题。
from flask import Flask,jsonify
from flask import request
import face_recognition
import json
app = Flask(__name__)
@app.route('/')
def index():
return ''
@app.route('/valid_faces', methods=['POST'])
def POST():
if request.method == 'POST':
# getting the images url from the request
print('....')
name1 = request.files['file'] if request.files.get('file') else None
print('....')
print (name1) # name2 = request.form.get('name2')
# map the url to the ones in the folder images
firstImage = name1
# loading the image inside a variable
firstImage = face_recognition.load_image_file(firstImage)
result=face_recognition.face_locations(firstImage)
if result:
# x={'valid_faces':True}
# return jsonify(x)
return "True"
else:
# x={'valid_faces':False}
# return jsonify(x)
return "False"
if __name__ == "__main__":
app.run(debug=True)
request
以调查其中的内容。 - Vaibhav Vishal