MCPcopy
hub / github.com/pyload/pyload / route

Method route

module/lib/bottle.py:643–685  ·  view source on GitHub ↗

A decorator to bind a function to a request URL. Example:: @app.route('/hello/:name') def hello(name): return 'Hello %s' % name The ``:name`` part is a wildcard. See :class:`Router` for syntax details. :param

(self, path=None, method='GET', callback=None, name=None,
              apply=None, skip=None, **config)

Source from the content-addressed store, hash-verified

641 return urljoin(urljoin('/', scriptname), location)
642
643 def route(self, path=None, method='GET', callback=None, name=None,
644 apply=None, skip=None, **config):
645 """ A decorator to bind a function to a request URL. Example::
646
647 @app.route('/hello/:name')
648 def hello(name):
649 return 'Hello %s' % name
650
651 The ``:name`` part is a wildcard. See :class:`Router` for syntax
652 details.
653
654 :param path: Request path or a list of paths to listen to. If no
655 path is specified, it is automatically generated from the
656 signature of the function.
657 :param method: HTTP method (`GET`, `POST`, `PUT`, ...) or a list of
658 methods to listen to. (default: `GET`)
659 :param callback: An optional shortcut to avoid the decorator
660 syntax. ``route(..., callback=func)`` equals ``route(...)(func)``
661 :param name: The name for this route. (default: None)
662 :param apply: A decorator or plugin or a list of plugins. These are
663 applied to the route callback in addition to installed plugins.
664 :param skip: A list of plugins, plugin classes or names. Matching
665 plugins are not installed to this route. ``True`` skips all.
666
667 Any additional keyword arguments are stored as route-specific
668 configuration and passed to plugins (see :meth:`Plugin.apply`).
669 """
670 if callable(path): path, callback = None, path
671 plugins = makelist(apply)
672 skiplist = makelist(skip)
673 def decorator(callback):
674 # TODO: Documentation and tests
675 if isinstance(callback, basestring): callback = load(callback)
676 for rule in makelist(path) or yieldroutes(callback):
677 for verb in makelist(method):
678 verb = verb.upper()
679 route = Route(self, rule, verb, callback, name=name,
680 plugins=plugins, skiplist=skiplist, **config)
681 self.routes.append(route)
682 self.router.add(rule, verb, route, name=name)
683 if DEBUG: route.prepare()
684 return callback
685 return decorator(callback) if callback else decorator
686
687 def get(self, path=None, method='GET', **options):
688 """ Equals :meth:`route`. """

Callers 5

mountMethod · 0.95
getMethod · 0.95
postMethod · 0.95
putMethod · 0.95
deleteMethod · 0.95

Calls 2

makelistFunction · 0.85
decoratorFunction · 0.85

Tested by

no test coverage detected