使用Django创建RESTful API
Agenda
1.What is an api
Api refers to application programming interface
It is a set of subroutine definitations, protocols and tools for building application software.
It helps in connecitng various software components
An api make it easier for developers to use certain technologies in building applications by using certain predefined operations.
2.Introduciton to Rest Framework
- It describe an architecture which stands for REpresentaionl State Transfer
- It is used for web based architecture for data communication
- It uses HTTP to make calls between machines
The following HTTP methods are most commonly used in a REST based architecture:
GET records and retrieve the data
PUT is used to change the state or update a resources which can be a file it can be object or any block
POST is usually used to create the resources
DELETE is used to remove that resource
3.What is REST API?
When Web Service use REST architecture, they are called RESTFul APIs or REST APIs.
A REST API is a set of web addresses that respond with pure information, not a formatted web pge
An api returens json, which is a common format. You'll see all of information surrounded with quotation marks, {} ,[] and descriptive titles for each bit of info.
4.Demo-Create a Restful api
Open the terminal and type the following command for Django installation
pip install djangorestframework
python manage.py makemigrations
python manage.py migrate
Create a user
run server:
python manage.py runserver
References:
Video Django Rest Framework | How to Create a RESTful API Using Django | Django Tutorial | Edureka
使用Django创建RESTful API的更多相关文章
- Django编写RESTful API(一):序列化
欢迎访问我的个人网站:www.comingnext.cn 关于RESTful API 现在,在开发的过程中,我们经常会听到前后端分离这个技术名词,顾名思义,就是前台的开发和后台的开发分离开.这个技术方 ...
- Django编写RESTful API(四):认证和权限
欢迎访问我的个人网站:www.comingnext.cn 前言: 按照前面几篇文章里那样做,使用Django编写RESTful API的基本功能已经像模像样了.我们可以通过不同的URL访问到不同的资源 ...
- python 全栈开发,Day95(RESTful API介绍,基于Django实现RESTful API,DRF 序列化)
昨日内容回顾 1. rest framework serializer(序列化)的简单使用 QuerySet([ obj, obj, obj]) --> JSON格式数据 0. 安装和导入: p ...
- Django编写RESTful API(二):请求和响应
欢迎访问我的个人网站:www.comingnext.cn 前言 在上一篇文章,已经实现了访问指定URL就返回了指定的数据,这也体现了RESTful API的一个理念,每一个URL代表着一个资源.当然我 ...
- 利用Django实现RESTful API(一)
RESTful API现在很流行,这里是它的介绍 理解RESTful架构和 RESTful API设计指南.按照Django的常规方法当然也可以实现REST,但有一种更快捷.强大的方法,那就是 Dja ...
- Django之Restful API
理解Restful架构:http://www.ruanyifeng.com/blog/2011/09/restful RESTful设计指南:http://www.ruanyifeng.com/blo ...
- 【从0到1,搭建Spring Boot+RESTful API+Shiro+Mybatis+SQLServer权限系统】03、创建RESTful API,并统一处理返回值
本节应用Spring对RESTful的支持,使用了如@RestController等注解实现RESTful控制器. 如果对Spring中的RESTful不太明白,请查看相关书籍 1.创建一个数据对象, ...
- Django编写RESTful API(五):添加超链接提高模型间的关联性
前言 在第四篇中,加入了用户模型,以及相关的认证和权限的功能.但是我们在使用的时候,会发现在访问http://127.0.0.1:8000/users/时看到的用户列表,不能够直接点击某个链接然后查看 ...
- Django编写RESTful API(六):ViewSets和Routers
欢迎访问我的个人网站:www.comingnext.cn 前言 在本系列的文章中,我在第一篇和第二篇文章中写的编写Django视图时,使用的都是基于函数的方法,并且每个视图函数之前都会加一个djang ...
随机推荐
- SqlServer 开篇简介
实例:我们的电脑中可以安装一个或多个SqlServer实例,每一个SqlServer实例可以包含一个或者多个数据库. 架构:数据库中,又有一个或者多个架构.架构里面包含:表,视图,存储过程. 文件与文 ...
- TCP SYN flood洪水攻击原理和防御破解
简介 TCP协议要经过三次握手才能建立连接: 于是出现了对于握手过程进行的攻击.攻击者发送大量的SYN包,服务器回应(SYN+ACK)包,但是攻击者不回应ACK包,这样的话,服务器不知道(SYN+AC ...
- MVC 创建Controllers 发生 EntityType has no key defined error
发生如图错误 只需要在对应的类中指定Key即可 添加引用 : System.ComponentModel.DataAnnotations 参考:https://stackoverflow.com/qu ...
- c# 读取txt文件中文乱码解决方法
之前做过一个项目,在程序运行目录下有个txt文件,文件内容是中文的时候会乱码, 后来用这个函数处理后,就不乱码了: private string GetPDA_Code() { ...
- Visual Studio Code 远程开发探秘
摘要: IDE新时代! 作者:SHUHARI 的博客 原文:Visual Studio Code 远程开发探秘 Fundebug按照原文要求转载,版权归原作者所有. 在以前的文章 有趣的项目 - 在浏 ...
- 去除数组空格 php
public function trimArray($params){ if (!is_array($params)) return trim($params); return array_map([ ...
- Django 练习班级管理系统二 -- 添加班级数据
在上一篇中(Django 练习班级管理系统一 https://www.cnblogs.com/klvchen/p/11078174.html),使用的是莫泰对话框的方式提交数据,适用于数据量少的操作. ...
- [Linux]F5负载均衡器
F5负载均衡器是硬件的负载均衡设备 F5配置最简单负载均衡,需要配置的参数有Node(节点).Pool(资源池).和Virtual Server(虚拟服务器),它们的关系是,先配置Node,然后配置V ...
- 关于苹果macOS更新到Catalina后出现的各种问题(持续更新)
一.Mac系统更新后 Git 不能用,提示 missing xcrun at:xxx xcrun: error: invalid active developer path (/Library/Dev ...
- 便宜的回文 (USACO 2007)(c++)
2019-08-21便宜的回文(USACO 2007) 内存限制:128 MiB 时间限制:1000 ms 标准输入输出 题目类型:传统 评测方式:文本比较 题目描述 追踪每头奶牛的去向是一件棘手的任 ...