Saturday, November 16, 2013

Tornado.js


PythonJS 0.8.5, includes a new module nodejs.tornado that provides an API compatibility layer with the Tornado web framework. This allows you to very quickly port your server side code written in Python and Tornado to PythonJS and NodeJS.

Example:

from nodejs.tornado import *

class MainHandler( tornado.web.RequestHandler ):
 def get(self, path=None):
  self.write('hello world')

handlers = [
 ('/', MainHandler)

]

app = tornado.web.Application( handlers )
app.listen( 8080 )

You can checkout the Tornado module and see a more complex example here.

No comments:

Post a Comment