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

我正在尝试使用curl和 python烧瓶将文件上传到服务器.下面我有如何实现它的代码.关于我做错什么的任何想法.
curl -i -X PUT -F name=Test -F filedata=@SomeFile.pdf "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 FileStorage
test = request.form['name']        # gives you the string 'Test'

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

相关文章

1、安装Apache。 1)执行如下命令,安装Apache服务及其扩展包...
一、先说一下用ansible批量采集机器信息的实现办法: 1、先把...
安装配置 1. 安装vsftpd 检查是否安装了vsftpd # rpm -qa | ...
如何抑制stable_secret读取关键的“net.ipv6.conf.all.stabl...
1 删除0字节文件 find -type f -size 0 -exec rm -rf {} ...
## 步骤 1:安装必要的软件包 首先,需要确保系统已安装 `dh...