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

原文地址:https://www.cnblogs.com/shengulong/p/9131292.html