Test your knowledge

Let's see whether you can answer the following questions correctly:

  1. Which of the following methods allows us to set the HTTP status code for a response in a subclass of tornado.web.RequestHandler?
    1. self.write_status
    2. self.__cls__.write_status_code
    3. self.set_satus
  1. Which of the following methods allows us to write the response in a subclass of tornado.web.RequestHandler?
    1. self.write_response
    2. self.write
    3. self.set_response
  1. The main building blocks for a RESTful API in Tornado are subclasses of which of the following classes?
    1. tornado.web.GenericHandler
    2. tornado.web.RequestHandler
    3. tornado.web.IncomingHTTPRequestHandler
  1. If we just want to support the GET and PATCH methods, we can override the SUPPORTED_METHODS class variable with which of the following values?
    1. ("GET", "PATCH")
    2. {0: "GET", 1: "PATCH"}
    3. {"GET": True, "PATCH": True, "POST": False, "PUT": False}
  1. The list of tuples for the tornado.Web.Application constructor is composed of which of the following?
    1. A regular expression (regexp) and a tornado.web.RequestHandler subclass (request_class)
    2. A regular expression (regexp) and a tornado.web.GenericHandler subclass (request_class)
    3. A regular expression (regexp) and a tornado.web.IncomingHTTPRequestHandler subclass (request_class)

  1. When we call the self.write method with a dictionary as an argument in a request handler, Tornado:
    1. Automatically writes the chunk as JSON but we have to manually set the value of the Content-Type header to application/json
    2. Requires us to use the json.dumps method and set the value of the Content-Type header to application/json
    3. Automatically writes the chunk as JSON and sets the value of the Content-Type header to application/json
  1. A calls to the tornado.escape.json_decode method with self.request.body as an argument in a request handler:
    1. Generates Python objects for the JSON string of the request body and returns the generated tuple
    2. Generates Python objects for the JSON string of the request body and returns the generated dictionary
    3. Generates Python objects for the JSON string of the request body and returns the generated list

 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.45.92