bottle动态路由类型转换

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from bottle import route, run




@route('/user/<id:int>')
def getid(id=''):
return "ID:%d"%id


@route('/weight/<weight:float>')
def getweight(weight=''):
return "weight:%f"%weight


@route('/url/<path:path>')
def getpath(path=''):
return path
#获取从url/后的所有部分

run(port=8080,debug=True,reloader=True)

转载请注明来源 https://tianweiye.github.io