tornado + sockjs-tornado handlers

65 views
Skip to first unread message

Алексей Силк

unread,
May 22, 2012, 9:00:54 AM5/22/12
to Tornado Web Server
Hello. Can ypu help me to understand how to work with different
handlers ... I use one tornado handler and one sockjs-tornado.
I'm always getting an error


import logging
logging.getLogger().setLevel(logging.DEBUG)

# 1. Create chat router
NewsRouter = sockjs.tornado.SockJSRouter(NewsConnection, '/news')

# 2. Create Tornado application
app = tornado.web.Application(
(r"/data", DataHandler)
[(r"/", IndexHandler)] + NewsRouter.urls ,

)

# 3. Make Tornado app listen on port 8080
app.listen(8080)

# 4. Start IOLoop
tornado.ioloop.IOLoop.instance().start()

Serge S. Koval

unread,
May 22, 2012, 1:56:28 PM5/22/12
to python-...@googlegroups.com
Hi,

 It's because you have syntax error when attempting to generate URL list.

 Do something like:
app = tornado.web.Application(
       [(r"/", IndexHandler), (r"/data", DataHandler)] + NewsRouter.urls,
   ) 

Serge.

Alexey Silk

unread,
May 22, 2012, 1:57:25 PM5/22/12
to python-...@googlegroups.com

Thank you! It helped …

Costa Farber

unread,
May 23, 2012, 1:08:22 AM5/23/12
to python-...@googlegroups.com
See this example of several handlers
    application = tornado.web.Application([
        (r"/", WixLogServiceIndexHTTPHandler, {'getInfoFromMongoDB':getInfoFromMongoDB}),
        (r"/static/(.*)", tornado.web.StaticFileHandler, {"path": "/opt/wix-log-service"}),
        (r"/api/wix-log", WixLogAnalyticsServerHTTP_handler, {'getInfoFromMongoDB':getInfoFromMongoDB, 'messageMapper':messageMapper}),
        (r"/api/getMissingFiles", WixLogGetMissingFilesHTTP_handler, {'getInfoFromMongoDB':getInfoFromMongoDB}),
        (r"/api/getMsgsByType", WixLogGetMessagesByTypeHTTP_handler, {'getInfoFromMongoDB':getInfoFromMongoDB}),
        (r"/wix-log", WixLogServiceIndexHTTPHandler, {'getInfoFromMongoDB':getInfoFromMongoDB}),
        (r"/api/isAlive",     WixLogServiceServerAliveHTTPHandler ),
        (r"/api/access-log", WixLogAccessLogHTTP_handler, {'getInfoFromMongoDB':getInfoFromMongoDB}),
        (r"/api/disp-access-log", WixLogDispatcherAccessLogHTTP_handler, {'getInfoFromMongoDB':getInfoFromMongoDB}),
    ])
Reply all
Reply to author
Forward
0 new messages