Python Flask api不是远程读取bytearray,而是本地读取

Python Flask api不是远程读取bytearray,而是本地读取,python,flask,python-bytearray,Python,Flask,Python Bytearray,我的client.py如下: import requests with open("image.jpg", "rb") as imageFile: # fil=imageFile.read() # print(fil) url = 'http://10.7.104.57:5000/julytest' headers = {'Content-Type': 'application/octet-stream'} try: response = req

我的client.py如下:

import requests
with open("image.jpg", "rb") as imageFile:
#   fil=imageFile.read()
#   print(fil) 
    url = 'http://10.7.104.57:5000/julytest'
    headers = {'Content-Type': 'application/octet-stream'}
    try:
        response = requests.post(url, files=[('image_data',('image.jpg', imageFile, 'image/jpg'))])
    except Exception as e:
        print(e)
print(response.text)
@app.route('/julytest', methods=['GET', 'POST'])
def get():
    print(request.files['image_data'])
    img = request.files['image_data']
    fil = img.filename
    image = cv2.imread(img.filename)
    rows, cols, channels = image.shape
    #do other processing
My server.py如下所示:

import requests
with open("image.jpg", "rb") as imageFile:
#   fil=imageFile.read()
#   print(fil) 
    url = 'http://10.7.104.57:5000/julytest'
    headers = {'Content-Type': 'application/octet-stream'}
    try:
        response = requests.post(url, files=[('image_data',('image.jpg', imageFile, 'image/jpg'))])
    except Exception as e:
        print(e)
print(response.text)
@app.route('/julytest', methods=['GET', 'POST'])
def get():
    print(request.files['image_data'])
    img = request.files['image_data']
    fil = img.filename
    image = cv2.imread(img.filename)
    rows, cols, channels = image.shape
    #do other processing
当我在本地(127.0.0.1:5000)运行客户端时,在我的机器上以及API所在的服务器上,我得到了期望的结果

但是,当我从本地计算机运行client.py到远程API计算机时,我得到一个错误

 error: (-215) (scn == 3 || scn == 4) && (depth == 0 || depth == 5) in function cvtColor
指示图像丢失或未读取。当我删除
行、列、通道=image.shape之前的注释时,我得到了确认

AttributeError: 'NoneType' object has no attribute 'shape'

OpenCV的版本在本地和远程上都是相同的,操作系统在这两台机器上都是ubuntu 14.04

你从哪里得到错误<代码>服务器
客户端
?行、列、通道=image.shape之前的指定注释在哪里?你的错误打印在哪里?
打印(request.files['image\u data'])
的输出是什么?@Sraw错误来自服务器…错误在客户端打印