MCPcopy Create free account
hub / github.com/datapane/datapane / route

Method route

python-client/src/datapane/_vendor/bottle.py:870–918  ·  view source on GitHub ↗

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

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

Source from the content-addressed store, hash-verified

868 if DEBUG: route.prepare()
869
870 def route(self,
871 path=None,
872 method='GET',
873 callback=None,
874 name=None,
875 apply=None,
876 skip=None, **config):
877 """ A decorator to bind a function to a request URL. Example::
878
879 @app.route('/hello/<name>')
880 def hello(name):
881 return 'Hello %s' % name
882
883 The ``<name>`` part is a wildcard. See :class:`Router` for syntax
884 details.
885
886 :param path: Request path or a list of paths to listen to. If no
887 path is specified, it is automatically generated from the
888 signature of the function.
889 :param method: HTTP method (`GET`, `POST`, `PUT`, ...) or a list of
890 methods to listen to. (default: `GET`)
891 :param callback: An optional shortcut to avoid the decorator
892 syntax. ``route(..., callback=func)`` equals ``route(...)(func)``
893 :param name: The name for this route. (default: None)
894 :param apply: A decorator or plugin or a list of plugins. These are
895 applied to the route callback in addition to installed plugins.
896 :param skip: A list of plugins, plugin classes or names. Matching
897 plugins are not installed to this route. ``True`` skips all.
898
899 Any additional keyword arguments are stored as route-specific
900 configuration and passed to plugins (see :meth:`Plugin.apply`).
901 """
902 if callable(path): path, callback = None, path
903 plugins = makelist(apply)
904 skiplist = makelist(skip)
905
906 def decorator(callback):
907 if isinstance(callback, basestring): callback = load(callback)
908 for rule in makelist(path) or yieldroutes(callback):
909 for verb in makelist(method):
910 verb = verb.upper()
911 route = Route(self, rule, verb, callback,
912 name=name,
913 plugins=plugins,
914 skiplist=skiplist, **config)
915 self.add_route(route)
916 return callback
917
918 return decorator(callback) if callback else decorator
919
920 def get(self, path=None, method='GET', **options):
921 """ Equals :meth:`route`. """

Callers 6

_mount_wsgiMethod · 0.95
getMethod · 0.95
postMethod · 0.95
putMethod · 0.95
deleteMethod · 0.95
patchMethod · 0.95

Calls 2

makelistFunction · 0.85
decoratorFunction · 0.85

Tested by

no test coverage detected