def clear_routes(app_name=None): app = bottle.default_app() routes = app.routes[:] app.routes.clear() app.router = bottle.Router() if app_name: for route in routes: if route.rule[1:].split("/")[0] != app_name: app.add_route(route)
def setUp(self): self.r = bottle.Router()
#!/usr/bin/env python # -*- coding: utf-8 -*- import re import bottle router = bottle.Router() # router.add('/static', 'GET', '/static') # env = {'PATH_INFO': '/static', 'REQUEST_METHOD': 'GET'} # def test(request): pass # router.add('/:test', 'GET', test) # env = {'PATH_INFO': '/test', 'REQUEST_METHOD': 'GET'} # # target, urlargs = router.match(env) # # print target # print urlargs old_rule_syntax = re.compile( '(\\\\*)(?:(?::([a-zA-Z_][a-zA-Z_0-9]*)?()(?:#(.*?)#)?)|(?:<([a-zA-Z_][a-zA-Z_0-9]*)?(?::([a-zA-Z_]*)(?::((?:\\\\.|[^\\\\>]+)+)?)?)?>))' ) rule_syntax = re.compile( '(\\\\*)(?:<([a-zA-Z_][a-zA-Z_0-9]*)?(?::([a-zA-Z_]*)(?::((?:\\\\.|[^\\\\>]+)+)?)?)?>)' ) # print '----------------------------------------' #