使用tastype的rest实现。

thinrest的Python项目详细描述


#thin rest


非常薄的一层在django之上,使用[tastype库](https://github.com/django tastypie/django tastypie/django tastypie/django tastypie/django tastypie/django tastypie)来实现restarestaapi的rest-rest-api(使用[tastypie>构建一个简单的接口,可以为两种类型的crud操作提供数据库表:

1。以列为基础,例如雇员(姓名、姓氏、地址、城市、州、邮编)


2。键值对,例如系统设置(设置名称、设置值)

``` pip安装thinrest``

2。将“thinrest”添加到“已安装的应用程序”设置中:

`` python
已安装的应用程序=(

“thinrest”,

````

3。包括thinrest url


``python
patterns=('',

url(r'^thinrest/',include('thinrest.url'),


``` ` ` `
` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `{
“名字”:“anurag”,
“姓氏”:“agarwal”,
“address”:“wakad”、
“city”:“pune”、
“state”:“maharashtra”、
“邮政编码”:“411057”
}、
“model”:“thinrest.employee”、
“pk”:1
“`````

“employee list:get http://www.example.com/thinrest/api/v1/employee?format=json

员工详细信息:获取http://www.example.com/thinrest/api/v1/employee/1?format=json

employee create/update:post http://www.example.com/thinrest/api/v1/employee/

employee detele:delete http://www.example.com/thinrest/api/v1/employee/1/

对于此类表,将“id”传递给rest将不起作用。因此,在该表的api中很少做一些调整,将列“name”作为输入参数处理。


示例数据:

```{
“fields”:{
“name”:“email”,
“value”:1
},
“model”:“thinrest.systemsetting”,
“pk”:1
`````

设置列表:获取http://www.example.com/thinrest/api/v1/setting?format=json

设置详细信息:获取http://www.example.com/thinrest/api/v1/setting/email?format=json

设置创建/更新:发布http://www.example.com/thinrest/api/v1/setting/

设置详细信息:删除http://www.example.com/thinrest/api/v1/employee/setting/email/

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Apache Flink外部Jar   创建和强制转换对象数组时发生java错误   Java,添加数组   具有相同包结构和类的java JAR   java Jenkins未能构建Maven项目   java为什么一个forloop比另一个更快,尽管它们做的“一样”?   servlets在将“/”站点迁移到Java EE包时处理contextpath引用   无法解析java MavReplugin:2.21或其某个依赖项   泛型如何编写比较器来泛化Java中的两种类型的对象?   java Android Emulator未在netbeans上加载   多线程Java使用线程对数组中的数字求和:在同步块中使用新变量作为锁:差异   java如何在JSP/servlet中设置<input>标记的值?