예제 #1
0
def app(environ, start_response):
    # 创建一个Request对象
    # Create a Request object
    request = wsgi.Request(environ)
    
    # 创建一个Response对象
    # Create a Response object
    response = wsgi.Response()
    
    # 创建一个Context对象
    # Create a Context object
    context = wsgi.Context(request, response) 
    
    # 添加before_dispatch事件,以便进行认证检查。
    # Add event before_dispatch to do authentication.
    if not fire_event('before_dispatch', context=context):
        # 激活dispatch事件,sayhi会被调用
        # Fire event dispatch, sayhi gets called
        fire_event('dispatch', context=context) 
    
    # WSGI调用
    # WSGI call
    start_response(response.get_response_status(), response.get_response_headers()) 
    
    # 返回输出内容
    # Return output
    return response.get_response_body() 
예제 #2
0
def app(environ, start_response):
    # 创建一个Request对象
    # Create a Request object
    request = wsgi.Request(environ)
    
    # 创建一个Response对象
    # Create a Response object
    response = wsgi.Response()
    
    # 创建一个Context对象
    # Create a Context object
    context = wsgi.Context(request, response) 
    
    # 激活dispatch事件,sayhi会被调用
    # Fire dispatch event, sayhi gets called
    fire_event('dispatch', context=context) 
    
    # WSGI调用
    # WSGI call
    start_response(response.get_response_status(), response.get_response_headers()) 
    
    # 返回输出内容
    # Return output
    return response.get_response_body()