更新时间:2023-11-27 15:35:52
这对我有用:
curl -F "file=@image.jpg" http://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!'