The main building blocks for a RESTful API in Tornado are subclasses of which the following classes:
tornado.web.GenericHandler
tornado.web.RequestHandler
tornado.web.IncomingHTTPRequestHandler
If we just want to support the
GET
andPATCH
methods, we can override theSUPPORTED_METHODS
class variable with which of the following values:("GET", "PATCH")
{0: "GET", 1: "PATCH"}
{"GET": True, "PATCH": True, "POST": False, "PUT": False}
The list of tuples for a the
tornado.Web.Application
constructor is composed of:A regular expression (
regexp
) and atornado.web.RequestHandler
subclass (request_class
).A regular expression (
regexp
) and atornado.web.GenericHandler
subclass (request_class
).A regular expression (
regexp
) and atornado.web.IncomingHTTPRequestHandler
subclass (request_class
).
When we call the
self.write
method with a dictionary as an argument in a request handler, Tornado:Automatically writes the chunk as JSON but we have to manually set the value of the...
You're reading from Building RESTful Python Web Services
The rest of the page is locked
You have been reading a chapter from
Building RESTful Python Web ServicesPublished in: Oct 2016Publisher: PacktISBN-13: 9781786462251
© 2016 Packt Publishing Limited All Rights Reserved