一、get请求

页面请求地址:http://127.0.0.1:5000/test/5?username=test

视图函数接口路径:/test/<int:id>

flask接口传参

postman传递参数:使用GET请求方式传参

flask接口传参

 

注意:既可以获取路径上的参数也可以获取postman传递的参数

二、post请求

页面请求地址:http://127.0.0.1:5000/test/5

视图函数接口:/test/<int:id>

flask接口传参

 

postman传递参数:使用post请求方式传参(post传参的好处在于不会将参数放在路径上)

flask接口传参

 

注意:post传递json格式参数需要使用json.loads(request.get_data)接收并序列化参数

 

相关文章:

  • 2021-04-30
  • 2021-11-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-15
猜你喜欢
  • 2021-06-13
  • 2022-12-23
  • 2021-05-05
  • 2022-12-23
  • 2021-09-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案