$ pip install tornado==4.3
import tornado.web
import tornado.ioloop
class IndexHandler(tornado.web.RequestHandler):
def initialize(self, subject):
self.subject = subject
def get(self, name):
self.write("hello %s, at %s" % (name, self.subject))
def make_app():
return tornado.web.Application([
(r'/hello/(.*)', IndexHandler, dict(subject="hello page"))
])
if __name__ == "__main__":
app = make_app()
app.listen(8000)
tornado.ioloop.IOLoop.current().start()
网友评论