Day06作业
作业
1. 在自己电脑上安装搭建项目,并完成上面的快速体验开发接口的代码测试。
Postman接口测试
使用postman接口测试
-
GET请求测试
GET http://127.0.0.1:8000/students/
返回数据
{ "stu": "http://127.0.0.1:8000/students/stu/" }
获取所有的数据接口
GET http://127.0.0.1:8000/students/stu/
返回数据
[ { "id": 1, "name": "surpass", "sex": true, "age": 18, "class_num": "301", "description": "爱彩菇凉的小蘑菇" }, { "id": 2, "name": "surpass", "sex": true, "age": 18, "class_num": "301", "description": "爱彩菇凉的小蘑菇" }, { "id": 3, "name": "surpass", "sex": true, "age": 18, "class_num": "301", "description": "爱彩菇凉的小蘑菇" } ]
-
POST请求测试(增加一条记录)
POST http://127.0.0.1:8000/students/stu/
body JSON(application/json)
{ "name": "djy", "sex": false, "age": 18, "class_num": "303", "description": "爱彩菇凉的小蘑菇" }
返回数据
{ "id": 5, "name": "djy", "sex": false, "age": 18, "class_num": "303", "description": "爱彩菇凉的小蘑菇" }
查询id为 5的学生数据
GET http://127.0.0.1:8000/students/stu/5/
返回数据
{ "id": 5, "name": "djy", "sex": false, "age": 18, "class_num": "303", "description": "爱彩菇凉的小蘑菇" }
-
PUT 请求测试
update一条数据
PUT http://127.0.0.1:8000/students/stu/5/
要修改的数据
body JSON(application/json)
{ "name": "djy_xfc", "sex": false, "age": 16, "class_num": "303", "description": "笑口常开" }
返回数据
{ "id": 5, "name": "djy_xfc", "sex": false, "age": 16, "class_num": "303", "description": "笑口常开" }
查询更新后的数据
GET http://127.0.0.1:8000/students/stu/5/
返回数据
{ "id": 5, "name": "djy_xfc", "sex": false, "age": 16, "class_num": "303", "description": "笑口常开" }
-
DELETE 请求测试
删除一条数据
DELETE http://127.0.0.1:8000/students/stu/5/
查询删除后数据
GET http://127.0.0.1:8000/students/stu/5/
返回数据
{ "detail": "Not found." }