Writing request handlers

The main building blocks for a RESTful API in Tornado are subclasses of the tornado.web.RequestHandler class, that is, the base class for HTTP request handlers in Tornado. We just need to perform the following tasks to build our RESTful API that interacts with a drone:

  1. Create a subclass of the RequestHandler class and declare the methods for each supported HTTP verb
  2. Override the methods to handle HTTP requests
  3. Map the URL patterns to each subclass of the RequestHandler superclass in the tornado.web.Application instance that represents the Tornado web application

We will create the following subclasses of the RequestHandler class:

Class name

Description

HexacopterHandler

This class processes the HTTP ...

Get Hands-On RESTful Python Web Services - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.