使用curl将文件上传到python烧瓶服务器

使用curl将文件上传到python烧瓶服务器,第1张

概述我正在尝试使用curl和 python烧瓶将文件上传到服务器.下面我有如何实现它的代码.关于我做错什么的任何想法. curl -i -X PUT -F name=Test -F [email protected] "http://localhost:5000/" @app.route("/", methods=['POST','PUT'])def hello(): file 我正在尝试使用curl和 python烧瓶将文件上传到服务器.下面我有如何实现它的代码.关于我做错什么的任何想法.
curl -i -X PUT -F name=Test -F [email protected] "http://localhost:5000/" @app.route("/",methods=['POST','PUT'])def hello():    file = request.files['Test']    if file and allowed_file(file.filename):        filename=secure_filename(file.filename)        print filename    return "Success"

以下是服务器发回的错误

<!DOCTYPE HTML PUBliC "-//W3C//DTD HTML 3.2 Final//EN"><Title>400 Bad Request</Title><h1>Bad Request</h1><p>The browser (or proxy) sent a request that this server Could not understand.</p>

提前致谢.

解决方法 您的卷曲命令意味着您正在传输两个表单内容,一个名为filedata的文件和一个名为name的表单字段.所以你可以这样做:
file = request.files['filedata']   # gives you a fileStoragetest = request.form['name']        # gives you the string 'Test'

但request.files [‘Test’]不存在.

总结

以上是内存溢出为你收集整理的使用curl将文件上传到python烧瓶服务器全部内容,希望文章能够帮你解决使用curl将文件上传到python烧瓶服务器所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/1048269.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存