flask RESTful api学习 WITH POSTMAN调试
来源:互联网 发布:手机的移动数据打不开 编辑:程序博客网 时间:2024/05/21 10:20
大环境需要有如下包
pip install flask
pip install flask-RESTful
将官网的例子粘到pycharm中
from flask import Flask, requestfrom flask.ext.restful import Resource, Apiapp = Flask(__name__)api = Api(app)todos = {}class TodoSimple(Resource): def get(self, todo_id): return {todo_id: todos[todo_id]} def put(self, todo_id): todos[todo_id] = request.form['data'] return {todo_id: todos[todo_id]}api.add_resource(TodoSimple, '/<string:todo_id>')if __name__ == '__main__': app.run(debug=True)
官网是在linux环境下调试代码,使用curl命令,但是在windows上如果要使用,可以借助postman插件。
这是官网给出的测试案例
$ curl http://localhost:5000/todo1 -d "data=Remember the milk" -X PUT{"todo1": "Remember the milk"}$ curl http://localhost:5000/todo1{"todo1": "Remember the milk"}$ curl http://localhost:5000/todo2 -d "data=Change my brakepads" -X PUT{"todo2": "Change my brakepads"}$ curl http://localhost:5000/todo2{"todo2": "Change my brakepads"}
在postman中可以这样使用,
查看结果
阅读全文
0 0
- flask RESTful api学习 WITH POSTMAN调试
- Restful API接口调试工具推荐(Postman, HTTPie)
- Designing a RESTful API with Python and Flask
- Flask-restful API演示
- postman--api调试工具
- 使用 Flask-RESTful 设计 RESTful API
- Flask 学习篇一: 搭建Python虚拟环境,安装flask,并设计RESTful API。
- chrome api调试插件 postman
- API调试工具推荐--POSTMAN
- postman-api自动化调试图解
- Rest API学习笔记 --- 实现的 Flask 一个 RESTful API 服务器端 Demo
- Restful API调试
- 使用flask 构建基本的 restful api
- Python使用Flask搭建RESTful API
- 使用Flask搭建Restful API后端服务器
- Python Flask Restful API 基础篇
- 使用 Python 和 Flask 设计 RESTful API
- Python使用Flask搭建RESTful API
- 一致性hash算法
- maven安装配置
- lesson 10:用两个线程玩猜数字游戏,第一个线程负责随机给出1~100之间的一个整数,第二个线程负责猜出这个数。要求每当第二个线程给出自己的猜测后,第一个线程都会提示“猜小了”、“猜大了”或“猜
- 乐视洗牌,张昭升官,孙宏斌为何力挺张昭的乐视影业?
- pyCharm最新2017激活码
- flask RESTful api学习 WITH POSTMAN调试
- 事件委托
- Spring框架学习笔记
- 项目经理原则
- WORD中的格式控制符号
- RT-tests安装测试
- VM 启动报错 "Failed to lock the file" 解决办法
- 一些好的文章/博客/交流
- pdfelement 破解版V6.3.5.2806下载 | Wondershare PDFelement(PDF工具箱)官方中文版无需wondershare pdfelement 注册码