天天看點

Python Tornado的例子

寫好代碼,運作。

Python Tornado的例子
# coding: utf8

import tornado.ioloop
import tornado.web


class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.write("Hello, world")


class TestHandler(tornado.web.RequestHandler):
    def get(self):
        self.write("Hello Evilxr,This is you's Python!")


class meHandler(tornado.web.RequestHandler):
    def get(self):
        self.write("me, change the tornado")


application = tornado.web.Application([
    (r"/", MainHandler),
    (r"/test", TestHandler),
    (r"/me", meHandler)
])


if __name__ == "__main__":
    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()

# 127.0.0.1:8888

           
Python Tornado的例子

本地網址:

127.0.0.1:8888/test

127.0.0.1:8888