我想通过curl将图像发送到烧瓶服务器,我正在尝试此curl命令 curl -X POST -F file = image.jpg http:// 127.0.0.1:5000/ ,但是它在服务器端无法正常工作,我通过此代码处理图像 image = Image。 open(request.files ['file'])我正在尝试使用PIL读取图像 反正有这样做吗? 谢谢
I want to send an image by curl to flask server, i am trying this curl command curl -X POST -F file=image.jpg "127.0.0.1:5000/" but it did not work by the way on the server side i handle the image by this code image = Image.open(request.files['file']) i am trying to read the image using PIL Is there anyway to do this? Thanks in advance
推荐答案这对我有用:
curl -F "file=@image.jpg" localhost:5000/@很重要,否则您将遇到一个HTTP错误400(服务器无法理解请求)。我还删除了 -X POST位,因为这是不必要的。
The '@' is important, otherwise you end up with an http error 400 (server could not understand request). I've also dropped the "-X POST" bit as it's unnecessary.
我的烧瓶视图:
from PIL import Image @app.route("/", methods=["POST"]) def home(): img = Image.open(request.files['file']) return 'Success!'更多推荐
如何从curl请求将图像发送到Flask服务器
发布评论