def route(self, path, limit=False, time=None, key=lambda data: data.get("key"), reset=100000):
        _a = (key, limit, time, reset) # Avoid ambiguity with key=lambda inside define().
        def decorator(handler):
            def ratelimited(handler):
                # With @app.route(path, limit=True), rate limiting is applied.
                # The handler function is wrapped in a function that first calls
                # RateLimit()(key, path, limit, time) before calling the handler.
                # By default, a query parameter "key" is expected.
                # If the key is known, apply rate limiting (429 Too Many Requests).
                # If the key is unknown or None, deny access (403 Forbidden).
                # If the key is unknown and a default limit and time are given,
                # add the key and grant the given credentials, e.g.:
                # @app.route(path, limit=100, time=HOUR, key=lambda data: app.request.ip).
                # This grants each IP-address a 100 requests per hour.
                @self.thread(START)
                def connect():
                    g.rate = RateLimit(name=self._rate)
                def wrapper(*args, **kwargs):
                    self = cp.request.app.root
                    self._ratelimited = True
                    v = handler(*args, **kwargs)
                    if self._ratelimited: # App.unlimited() in handler() sets it to False.
                        self.rate(
                              key = _a[0](cp.request.params),
                             path = "/" + cp.request.path_info.strip("/"),
                            limit = _a[1], # Default limit for unknown keys.
                             time = _a[2], # Default time for unknown keys.
                            reset = _a[3]  # Threshold for clearing cache.
                        )
                    return v
                return wrapper
            if limit is True or (limit is not False and limit is not None and time is not None):
                handler = ratelimited(handler)
            self.router[path] = handler # Register the handler.
            return handler
        return decorator
The @app.route(path) decorator defines the handler function for the given path.
dataset/ETHPy150Open clips/pattern/pattern/server/__init__.py/Application.route