使用curl send post requues时无法生成日志

2024-04-27 03:22:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试测试我的flask应用程序的注册函数。你知道吗

curl -X POST -H "application/json" -d "email=12345671111@qqcom&name=test123"  http://192.168.50.4:5000/register
{
  "message": "\u9519\u8bef\u7684 JSON \u6570\u636e\u683c\u5f0f"
}%

返回的消息非常奇怪,烧瓶日志显示:

"POST /register HTTP/1.1" 400 -

但如果我点击网页中的注册按钮,这是正常的。你知道吗

192.168.50.1 - - [15/Nov/2015 13:16:49] "POST /register HTTP/1.1" 400 -
192.168.50.1 - - [15/Nov/2015 13:22:03] "OPTIONS /register HTTP/1.1" 200 -
the params is {u'fullname': u'test11828732', u'email': u'hshdshhvhd@qq.com'}

不知道这个,希望有人能帮我,提前谢谢!你知道吗


Tags: 函数nameregisterjson应用程序httpflaskapplication
1条回答
网友
1楼 · 发布于 2024-04-27 03:22:42

正如错误消息所说,您没有传递有效的JSON数据。curl命令不正确:没有正确设置content-type头,并且传递的是表单编码的数据而不是JSON数据。你知道吗

curl -X POST -H 'Content-Type: application/json' -d '{"email": "12345671111@qq.com", "name": "test123"}'

相关问题 更多 >