def rebase(base):
    if not base: #no rebase needed
        return bottle.app()

    oldApp = bottle.app.pop()
    newApp = bottle.app.push()
    for route in oldApp.routes:
        route.rule = "{0}{1}".format(base, route.rule)
        newApp.add_route(route)
        route.reset() #reapply plugins on next call
    return newApp
Create new app using current app routes prefixed with base
dataset/ETHPy150Open saltstack/halite/halite/server_bottle.py/rebase