Web to py enterprise web framework - p 27

CHAPTER 9 SERVICES The W3C defines a web service as “a software system designed to support interoperable machine-to-machine interaction over a network”. This is a broad definition, and it encompass a large number of protocols not designed for machine-to-human communication, but for machine-to-machine communication such as XML, JSON, RSS, etc. web2py provides, out of the box, support for the many protocols, including XML, JSON, RSS, CSV, XMLRPC, JSONRPC, AMFRPC. web2py can also be extended to support additional protocols. Each of those protocols is supported in multiple ways, and we make a distinction between: • Rendering the output of a function in a given. | CHAPTER 9 SERVICES The W3C defines a web service as a software system designed to support interoperable machine-to-machine interaction over a network . This is a broad definition and it encompass a large number of protocols not designed for machine-to-human communication but for machine-to-machine communication such as XML JSON RSS etc. WEB2py provides out of the box support for the many protocols including XML JSON RSS CSV XMLRPC JSONRPC AMFRPC. WEB2py can also be extended to support additional protocols. Each of those protocols is supported in multiple ways and we make a distinction between Rendering the output of a function in a given format for example XML JSON RSS CSV Remote Procedure Calls for example XMLRPC JSONRPC AM-FRPC WEB2PY Enterprise Web Framework 2nd Ed. By Massimo Di Pierro 245 Copyright 2009 246 SERVICES Rendering a dictionary 1 2 3 1 1 2 3 1 2 3 4 1 HTML XML and JSON Consider the following action def count or 0 1 return diet counter now This action returns a counter that is increased by one when a visitor reloads the page and the timestamp of the current page request. Normally this page would be requested via http 8000 app default count and rendered in HTML. Without writing one line of code we can ask WEB2py to render this page using a different protocols by adding an extension to the URL http 8000 app default http 8000 app default http 8000 app default son The dictionary returned by the action will be rendered in HTML XML and JSON respectively. Here is the XML output document counter 3 counter now 2009-08-01 13 00 00 now document Here is the JSON output counter 3 now 2009-08-01 13 00 00 Notice that date time and datetime objects are rendered as strings in ISO format. This is not part of the JSON standard but a WEB2py convention. How it works When for example the .xml extension is called WEB2py looks for a template .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.