美文网首页
tornado开始

tornado开始

作者: 永恒芳华 | 来源:发表于2019-04-18 08:09 被阅读0次
    $ 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()
    

    相关文章

      网友评论

          本文标题:tornado开始

          本文链接:https://www.haomeiwen.com/subject/kxwawqtx.html