Exemple #1
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-p", "--port", metavar="PORT=3000", type=int, default=3000)
    myapp.setup_argparser(parser)
    args = parser.parse_args()
    myapp.setup_app(args)
    
    factory = WebSocketServerFactory("ws://localhost:%d" % args.port)
    factory.protocol = WebSocketWrapperProtocol
    
    root = Root()
    root.putChild("ws", WebSocketResource(factory))
    reactor.listenTCP(args.port, Site(root))
    reactor.run()
Exemple #2
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-p", "--port", metavar="PORT=3000", type=int, default=3000)
    myapp.setup_argparser(parser)
    args = parser.parse_args()
    myapp.setup_app(args)
    
    tornado.web.Application([
        (r"/", MainHandler),
        (r"/ws", WebSocketHandler)
    ], **{
        "cookie_secret": "myapp_secret_string",
        "template_path": os.path.join(os.path.dirname(__file__), "templates"),
        "static_path": os.path.join(os.path.dirname(__file__), "static"),
        "xsrf_cookies": True,
    }).listen(args.port)
    tornado.ioloop.IOLoop.instance().start()
Exemple #3
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-p", "--port", metavar="PORT=3000", type=int, default=3000)
    myapp.setup_argparser(parser)
    args = parser.parse_args()
    myapp.setup_app(args)
    
    cherrypy.config.update({
        "server.socket_host": "127.0.0.1",
        "server.socket_port": args.port
    })
    WebSocketPlugin(cherrypy.engine).subscribe()
    cherrypy.tools.websocket = WebSocketTool()
    cherrypy.quickstart(Root(), "", config={
        "/": {
            "tools.staticdir.on": True,
            "tools.staticdir.dir": os.path.abspath(
                os.path.join(os.path.dirname(__file__), "public/")),
        },
        "/ws": {
            "tools.websocket.on": True,
            "tools.websocket.handler_cls": WebSocketHandler,
        }
    })