【问题标题】:Getting an error while giving POST request发出 POST 请求时出错
【发布时间】:2021-04-11 04:45:44
【问题描述】:

The error that I'm getting on Postman

我的代码:

@app.route('/getcoordinates', methods=['GET', 'POST'])
def get_image():
    if request.method == 'POST':
        file = request.files['image'].read()
        #use numpy to construct an array from the bytes
        x = np.fromstring(file, dtype='uint8')
        #decode the array into an image
        img = cv2.imdecode(x, cv2.IMREAD_UNCHANGED)
        #In output we get the x&y coordinates of the face bounding box
        output = give_coordinates(img)
    else:
        return "Error: No image provided. Please specify a image."

    return jsonify(output)

或者谁能告诉我如何在 POST 请求中提供图片,因为我认为这就是问题所在。

【问题讨论】:

    标签: amazon-web-services api post amazon-ec2 request


    【解决方案1】:

    可能在这里回答:"Post Image data using POSTMAN"

    这不是您在邮递员上发送文件的方式。你所做的只是发送一个字符串,它是你的图像的路径,仅此而已。

    你应该做的是;

    将请求方法设置为 POST 后,单击“正文”选项卡。 选择表单数据。在第一行,您将看到名为 key 和 value 的文本框。将“图像”写入密钥。您将看到默认设置为“文本”的值类型。制作文件并上传您的文件。 然后选择“原始”并粘贴您的 json 文件。同样在二元选项旁边,您会看到单击了“文本”。使其成为 JSON。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-10-21
      • 1970-01-01
      • 2022-01-06
      • 2019-03-19
      • 2021-12-13
      • 2021-11-26
      相关资源
      最近更新 更多