cors = CORS(app, resources={r"/*": {"origins": "*"}})
@app.route('/uploads', methods=['POST','OPTIONS'])
@cross_origin()
def upload_file():
file = request.files['image']
print file
# if file and allowed_file(file.filename):
if file and allowed_file(file.filename):
filename = secure_filename(file.filename)
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
data={'message':'success'}
return jsonify(data)
当我尝试从同一网络的其他计算机的POSTMAN上传文件时,我收到了BAD请求,但该文件在我的POSTMAN中有效。我不知道发生了什么事?但是我通过其他计算机的邮递员访问其他路由,只有文件上传路由给出了错误的请求。我也检查了文件夹权限。
我尝试编写自己的装饰器,但仍然遇到相同的错误
我可以从我自己的邮递员上传文件,但是无法从同一网络上的其他计算机邮递员上传文件。
我认为它存在跨域问题,但无法理解