模块概述篇2--tornado.web

作者: 交话费的时间放寒假 | 来源:发表于2016-10-24 22:37 被阅读0次

    1、
    #web app对象,具有router分发的功能
    class Application(object)
    def add_handlers(self, host_pattern, host_handlers) //添加handler的 host的route规则
    def add_transform(self, transform_class)//添加transform中间件,加工_write_buffer
    def _get_host_handlers(self, request) //根据request获取handler,router的核心逻辑
    def start_request(self, server_conn, request_conn)//httpserver的委托方法
    2、

    class RequestHandler//请求handler对象
    子类:
    ErrorHandler//用于构造一个错误的返回,status_code自己提交
    RedirectHandler//构造一个302返回
    StaticFileHandler//构建一个静态资源handler
    //(r"/content/(.*)", web.StaticFileHandler, {"path": "/var/www"}),
    FallbackHandler//分发给其他http服务
    //wsgi_app = tornado.wsgi.WSGIContaine
    //django.core.handlers.wsgi.WSGIHandler())application = tornado.web.Application([   
    //(r"/foo", FooHandler),    (r".*", FallbackHandler, dict(fallback=wsgi_app),
    //])
    

    3、

    class OutputTransform//返回的输出流转换
    子类:
    GZipContentEncoding
    

    4、

    其他:
    UIModule
    子类:
    TemplateModule模板

    相关文章

      网友评论

        本文标题:模块概述篇2--tornado.web

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