The original is here: http://hmw.iteye.com/blog/1190827TP comes with Api,get request interface/** * Show Resource list * * @return \think\response */Public Function index (Request $request) {//$requ Est_method = Strtolower ($_server[' request_method ');//$return _onj = new Restrequest ();//$data = db (' Shopgo ODS ')->select (); $data = restutils::p rocessrequest (); $method = $data->getmethod ();//Print_r ($method);
Advantage: Data and style separationDisadvantage: not complete. City retrieval is not supported.
Google Code: http://code.google.com/p/weather-china/
Weather-China encapsulates weather RSS feed provided by Yahoo and provides a rest API interface in JSON format. To obtain weather forecasts for a city, such as Beijing, send the following GET request:
Http://weather-china.appspot.com/
still missing from our API.Unlike the API endpoints we wrote earlier, we don't want to use JSON, instead of the Web page's representation. The REST Framework provides 2 styles of HTML transformations, one for processing HTML using template rendering, and the other for processing pre-rendered HTML. The second renderer is the one we'd like to use at this endpoint.
Serialization of django-rest-framework,
Preface:I learned about rest-framework serialization yesterday, so I wrote a blog record. Official Website: http://www.django-rest-framework.org/tutorial/1-serialization/?working-with-serializers.
Frontend and backend Separation: Fron
", "Port": 00000002}], other element names see "Ryu Documentation" P282 actionsReturn result: integer, HTTP status code, 200 indicates success of adding flow table entryResults Example: 200,403,404#delete_flow_entry (dpid,match,priority,actions)Parameters:Dpid is a string, such as "0000000000000001"Match is a dictionary, such as match = {"In_port": 00000001}, the name of the other key is shown in "Ryu documentation" P161 Flow Match StructurePriority is a string, such as "1111"Actions are lists,
1. Get all subweb information (sub site):var // Web Absolute Url, {0}The returned data:2. Get all the list and library:var listlibinfo = "/_api/web/lists? $filter =hidden ne true $expand =rootfolder,hasuniqueroleassignments $select =title,id,parentweburl,basetype,items,roleassignments,itemcount,rootfolder/serverrelativeurl, rootfolder/itemcount,hasuniqueroleassignments $orderby =title ";The returned data is as follows, note that BaseType has four values: 0 is list, 1 is library, 4 is survey, an
["Predictions"] = []# Loop over the results and add them to the list of# returned predictions for(Imagenetid, label, prob)inchresults[0]: R = {"Label": Label,"Probability":float(Prob)} data["Predictions"].append (R)# indicate that's the request was a successdata["Success"] =True# Return the data dictionary as a JSON responsereturnFlask.jsonify (data)Although it is a core part, it is very easy to be reused. is the process of reading the data and then processing it. # If This is the main thread o
Build "1, integrated swagger" based on the rest service framework under SPRINGMVC 1. Requirements backgroundSpringMVC本身就可以开发出基于rest风格的服务,通过简单的配置,即可快速开发出一个可供客户端调用的rest服务,通常这些服务要不就是用于手机app的开发,要不就是提供给第三方开发者使用,不管哪种情况,你都需要提供详细的说明给别人,而Swagger就是为这种情况而生的,通过在接口上的注解,生成可供第三方模拟测试和阅读的接口列表,既美观又使用,真是行走江湖之必备良药。【XmPlatform原创,转载的话请注明】下面
style as much as possible to follow the REST goals set out in the Dr. Roy Fielding's thesis. From the implementation level, Neolies RESTlet can be divided into three parts:
RESTlet API: This section designs the RESTlet framework, including the application, Component,route,connector,virtualhost, Resource, etc. included in the classic
]
The global settings configuration is as follows:
# Global rest_framework = {"default_permission_classes": ['api. utils. Permission. svippremission'],}
Three built-in Permissions
Django-rest-framework built-in permission basepermission
By default, there is no restriction on permissions.
class BasePermission(object): """ A base class from which all
HTTP programming model can publish WCF Service Operations to non-soap endpoints. Document address http://msdn.microsoft.com/zh-cn/library/bb412169.aspx
ASP. NET web API: This is completely implemented based on the HTTP model and is currently in the preview version,ASP. NETWeb APIs allow developers to open their applications over HTTPProgram, Data and services. This allows developers to make full use of HTTP as the protocol for applications. Applic
The content of this section
Django Rest Framework Installation
Django Rest framwwork Environment configuration
Simple example Description
Using the rest framework in Django
1.1 Installing the Django rest
Rest is a popular concept now, rest has become a more and more popular application on the web, more and more rest-based Web services, including Twitter, micro-blog is a rest as an external API, previously I have described the "Rest
variables allows us to better control API behavior, which is the recommended way to use it.4. URLs # tutorial/urls.py FromDjango.Conf.URLsImportPatterns,Url,IncludeFromRest_frameworkImportRoutersFromQuickStartImportViews Router=Routers.Defaultrouter()Router.Register(R' Users ',Views.Userviewset)Router.Register(R' Groups ',Views.Groupviewset) # wire up our API using automatic URL routing. # Additional
": "VVVVVVV",
"staff": { c10/> "Phone": "Xxxxxxxxxx",
"username": "Yuan"}}
Fail: Failure uses the above exception for processing: Custom_exception_handler
{
"code": 404,
"desc": "Not found. "
}
three. Paging Implementation
As shown in the result return value, many uses need to implement paging functionality, but the Django Rest Framework has its own paging capabilities that can
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.