curl如何发送json数据?如何发送form数据?python的restfull又该如何获取这些数据?

  1、python使用flask+flask_restfull框架写的api接口,做为服务

  2、curl 做为客户端发送数据

 

from flask import request

curl发送json的方法:curl -H "Content-Type: application/json" -X POST  --data '{"uid":"1"}'  http://127.0.0.1:8088/v1/intelli_press_end

python的接收json的方法:uid = request.json.get('uid')

 

curl发送form的方法:curl -X POST  --data 'uid=2&stop_type=normal'  http://127.0.0.1:8088/v1/intelli_press_end

flask接收form的方法:uid = request.form['uid']

 

参考:

1、https://my.oschina.net/code33/blog/417424

2、https://gist.github.com/subfuzion/08c5d85437d5d4f00e58

posted @ 2018-06-03 23:34  脚本小娃子  阅读(993)  评论(0编辑  收藏  举报