drf入门规范
一、web应用模式
- web应用模式分为两种,一种是前后端不分离,一种是前后端分离
- 前后端不分离
- 前后端分离
二、API接口
- 为了在团队内部形成共识,防止个人习惯差异造成的混乱,我们需要找到一个大家都认为好的接口实现规范,这个规范可以让后端编写的接口一目了然,降低双方合作的成本。
[En]
In order to form a consensus within the team and prevent confusion caused by differences in personal habits, we need to find an interface implementation specification that everyone thinks is good, and this specification can make the interface written by the back-end clear at a glance and reduce the cost of cooperation between both parties.*
- API接口:通过网络,规定了前后台信息交互规则的url链接,也就是前后台信息交互的 媒介
- web API接口的四大特点: url:长得像返回数据的url链接 请求方式:get、post、put、patch、delete 请求参数:json或xml格式的key-value类型数据 响应结果:json或xml格式的数据
```python
xml格式
https://api.map.baidu.com/place/v2/search?ak=6E823f587c95f0148c19993539b99295®ion=%E4%B8%8A%E6%B5%B7&query=%E8%82%AF%E5%BE%B7%E5%9F%BA&output=xml
json格式
https://api.map.baidu.com/place/v2/search?ak=6E823f587c95f0148c19993539b99295®ion=%E4%B8%8A%E6%B5%B7&query=%E8%82%AF%E5%BE%B7%E5%9F%BA&output=json
{