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:
- Create a subclass of the RequestHandler class and declare the methods for each supported HTTP verb
- Override the methods to handle HTTP requests
- 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 and PATCH methods for a hexacopter resource. |
LedHandler |
This class processes the HTTP GET and PATCH methods for an LED resource. |