Anton Shestakov <engored@ya.ru>, Tue, 12 Mar 2013 02:23:34 +0900
Status bar. Also could not resist dragging jQuery in.
app.py
Permissions: -rwxr-xr-x
from tornado.ioloop import IOLoop from tornado.options import define, options from tornado.web import Application, RequestHandler from tornado.websocket import WebSocketHandler rel = lambda *x: os.path.abspath(os.path.join(os.path.dirname(__file__), *x)) class MainHandler(RequestHandler): self.render('index.html') class EchoWebSocket(WebSocketHandler): logging.info('WebSocket opened from %s', self.request.remote_ip) EchoWebSocket.clients.append(self) def on_message(self, message): logging.info('got message from %s: %s', self.request.remote_ip, message) for client in EchoWebSocket.clients: client.write_message(message) logging.info('WebSocket closed') EchoWebSocket.clients.remove(self) define('listen', metavar='IP', default='127.0.0.1', help='listen on IP address (default 127.0.0.1)') define('port', metavar='PORT', default=8888, type=int, help='listen on PORT (default 8888)') define('debug', metavar='True|False', default=False, type=bool, help='enable Tornado debug mode: templates will not be cached ' 'and the app will watch for changes to its source files ' 'and reload itself when anything changes') options.parse_command_line() template_path=rel('templates'), static_path=rel('static'), application = Application([ application.listen(address=options.listen, port=options.port) IOLoop.instance().start() if __name__ == '__main__':