路由用来关联 URL 与程序函数:
@App.route('/hello')
动态 URL(含参数的 URL) 使函数可以获得 URL 中的参数信息:
- @App.route('/user/<username>')
- def show_user_profile(username):
- return 'User %s' % username
我们可以采用 < converter:variable_name > 对参数进行格式转换 (过滤), 常用的转换器包括:
int | 整数 |
float | 浮点数 |
path | 包含斜杠的字符串 |
来源: http://www.bubuko.com/infodetail-2982756.html