gpt4 book ai didi

python-3.x - 使用 cURL POST csv/文本文件

转载 作者:行者123 更新时间:2023-12-03 07:45:08 26 4
gpt4 key购买 nike

如何使用 cURL 将带有 csv 或文本文件的 POST 请求发送到在 localhost 上运行的服务器。

我尝试了 curl -X POST -d @file.csv http://localhost:5000/upload 但我得到了

{ "message": "The browser (or proxy) sent a request that this server could not understand." }

我的服务器是flask_restful API。预先非常感谢。

最佳答案

有许多替代方法可以实现此目的。一种方法是我使用过以下内容:

curl -F ‘data=@<file_location>’ <URL>

例如。 curl -F data=@data.csv localhost:5000/h

你的命令也可以像这样稍微改变

curl -X POST -H 'Content-Type: text/csv' -d @file.csv http://localhost:5000/upload

以上是多种方式中的一种,可以作为表单或数据的一部分发送,也可以多部分发送等,可以引用Medium Post

关于python-3.x - 使用 cURL POST csv/文本文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50998620/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com