如何解决在 Cloud Run 中部署的 Flask API 中的请求不起作用
我在 Flask 中有一个应用程序,它应该在每个 POST 请求中接收一个图像。该请求适用于本地运行的服务器,但不适用于我由 Cloud Run 实现的 API :(
我将不胜感激!
问候,海伦娜。
@app.route("/predict",methods=["GET","POST"])
def predict():
# initialize the data dictionary that will be returned from the view
data = {"success": False}
# ensure an image was properly uploaded to our endpoint
if flask.request.method == 'POST':
_file = flask.request.files['image']
if _file:
# read the image in PIL format
thermal_image = flask.request.files['image'].read()
# get thermal region on embedded image
try:
image = get_cropped_embedded(thermal_image)
#print(image)
except Exception as e:
print(e)
data = {"Success": 'Be positive!'}
return flask.jsonify(data)
################ More code
data.update({
"path": path,"success": True
})
else:
logging.info("No hot point found out. Exitting without classification.")
return flask.jsonify(data)
# return the data dictionary as a JSON response
return flask.jsonify(data)
if __name__ == "__main__":
app.run('0.0.0.0',port=5000)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。