带参数的页面

有时,您需要根据 url 参数返回不同的页面。例如:

http://yourdomain.com/article/3

显示了数据库中的第三篇文章。在这种情况下,这样注册页面:

@app.page('/article', 'Article')
def form_page(param):
    return [ ... the content of the page ... ]

然后,当用户带着 /article/<param> 这样的 url 时, param 部分将作为处理函数的第一个参数传递。

If you the page has multiple parameters in the url like /page_name?param_a=value_a&param_b=value_b, you can get them with the second parameter in your page handler:

@app.page('/detail', 'Detail Page')
def detail_page(arg, all_args):
    ... # all_args will be a dictionary of all the params