Adding CORS Support to a Tornado BaseHandler

How to enable CORS to your Tornado REST APIs

Quick How To

This is a short reference to modify a custom Tornado BaseHandler to support Cross-Origin Resource Sharing (CORS) so that your REST API can be used from other domains with out raising browser errors. Here is the code on how to accomplish that:

To use the code just use the new BaseHandler as an argument instead of the tornado.web.RequestHandler that is normally used.