def run_tornado(self, args):
server = self<EOL>import tornado.ioloop<EOL>import tornado.web<EOL>import tornado.websocket<EOL>ioloop = tornado.ioloop.IOLoop.current()<EOL>class DevWebSocketHandler(tornado.websocket.WebSocketHandler):<EOL><INDENT>def open(self):<EOL><INDENT>super(DevWebSocketHandler, self).open()<EOL>server.on_open(self)<EOL><DEDENT>def on_message(self, message):<EOL><INDENT>server.on_message(self, message)<EOL><DEDENT>def on_close(self):<EOL><INDENT>super(DevWebSocketHandler, self).on_close()<EOL>server.on_close(self)<EOL><DEDENT><DEDENT>class MainHandler(tornado.web.RequestHandler):<EOL><INDENT>def get(self):<EOL><INDENT>self.write(server.index_page)<EOL><DEDENT><DEDENT>server.call_later = ioloop.call_later<EOL>server.add_callback = ioloop.add_callback<EOL>app = tornado.web.Application([<EOL>(r"<STR_LIT:/>", MainHandler),<EOL>(r"<STR_LIT>", DevWebSocketHandler),<EOL>])<EOL>app.listen(self.port)<EOL>print("<STR_LIT>".format(self.port))<EOL>ioloop.start()<EOL>
Tornado dev server implementation