Skip to content

Instantly share code, notes, and snippets.

@yishenggudou
Forked from jholster/gist:2290574
Created November 19, 2013 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yishenggudou/7544237 to your computer and use it in GitHub Desktop.
Save yishenggudou/7544237 to your computer and use it in GitHub Desktop.
import tornado.web
import tornado.httpserver
import tornado.ioloop
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Greetings from the instance %s!" % tornado.process.task_id())
app = tornado.web.Application([
(r"/", MainHandler),
])
if __name__ == "__main__":
server = tornado.httpserver.HTTPServer(app)
server.bind(8888)
server.start(0) # autodetect number of cores and fork a process for each
tornado.ioloop.IOLoop.instance().start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment