| 123456789101112131415161718192021222324252627282930 | import tornado.webimport jsonimport numpy as npclass BaseHandler(tornado.web.RequestHandler):    def set_default_headers(self):        print("setting headers!!!")        self.set_header("access-control-allow-origin", "*")        self.set_header("Access-Control-Allow-Headers", "x-requested-with")        self.set_header('Access-Control-Allow-Methods', 'GET, PUT, DELETE, OPTIONS')        # HEADERS!        self.set_header("Access-Control-Allow-Headers", "access-control-allow-origin,authorization,content-type")    def options(self):        # no body        self.set_status(204)        self.finish()class NpEncoder(json.JSONEncoder):    def default(self, obj):        if isinstance(obj, np.integer):            return int(obj)        elif isinstance(obj, np.floating):            return float(obj)        elif isinstance(obj, np.ndarray):            return obj.tolist()        else:            return super(NpEncoder, self).default(obj)
 |