首页 > 代码库 > flask源码 -- url_for

flask源码 -- url_for

 

def url_for(endpoint, **values):
    """Generates a URL to the given endpoint with the method provided.     为一个给出的带有方法的endpoint生成一个url

    :param endpoint: the endpoint of the URL (name of the function)     endpoint: 就是视图函数的名字  
    :param values: the variable arguments of the URL rule               values:   不同参数(字典)
    """ 
    return _request_ctx_stack.top.url_adapter.build(endpoint, values)   待解决难点:栈 

 

url用法示例 

url_for(‘static‘, filename=‘favicon.ico‘)

flask源码 -- url_for