def register(self, app, options):
        """
        Register the blueprint to the sanic app.

        :param app: Instance of :class:`sanic.app.Sanic` class
        :param options: Options to be used while registering the
            blueprint into the app.
            *url_prefix* - URL Prefix to override the blueprint prefix
        """

        url_prefix = options.get("url_prefix", self.url_prefix)

        # Routes
        for future in self.routes:
            # attach the blueprint name to the handler so that it can be
            # prefixed properly in the router
            future.handler.__blueprintname__ = self.name
            # Prepend the blueprint URI prefix if available
            uri = url_prefix + future.uri if url_prefix else future.uri

            version = future.version or self.version

            app.route(
                uri=uri[1:] if uri.startswith("//") else uri,
                methods=future.methods,
                host=future.host or self.host,
                strict_slashes=future.strict_slashes,
                stream=future.stream,
                version=version,
                name=future.name,
            )(future.handler)

        for future in self.websocket_routes:
            # attach the blueprint name to the handler so that it can be
            # prefixed properly in the router
            future.handler.__blueprintname__ = self.name
            # Prepend the blueprint URI prefix if available
            uri = url_prefix + future.uri if url_prefix else future.uri
            app.websocket(
                uri=uri,
                host=future.host or self.host,
                strict_slashes=future.strict_slashes,
                name=future.name,
            )(future.handler)

        # Middleware
        for future in self.middlewares:
            if future.args or future.kwargs:
                app.register_middleware(
                    future.middleware, *future.args, **future.kwargs
                )
            else:
                app.register_middleware(future.middleware)

        # Exceptions
        for future in self.exceptions:
            app.exception(*future.args, **future.kwargs)(future.handler)

        # Static Files
        for future in self.statics:
            # Prepend the blueprint URI prefix if available
            uri = url_prefix + future.uri if url_prefix else future.uri
            app.static(
                uri, future.file_or_directory, *future.args, **future.kwargs
            )

        # Event listeners
        for event, listeners in self.listeners.items():
            for listener in listeners:
                app.listener(event)(listener)
def register ( self , app , options ) : url_prefix = options . get ( "url_prefix" , self . url_prefix ) for future in self . routes : future . handler . __blueprintname__ = self . name uri = url_prefix + future . uri if url_prefix else future . uri version = future . version or self . version app . route ( uri = uri [ 1 : ] if uri . startswith ( "//" ) else uri , methods = future . methods , host = future . host or self . host , strict_slashes = future . strict_slashes , stream = future . stream , version = version , name = future . name , ) ( future . handler ) for future in self . websocket_routes : future . handler . __blueprintname__ = self . name uri = url_prefix + future . uri if url_prefix else future . uri app . websocket ( uri = uri , host = future . host or self . host , strict_slashes = future . strict_slashes , name = future . name , ) ( future . handler ) for future in self . middlewares : if future . args or future . kwargs : app . register_middleware ( future . middleware , * future . args , ** future . kwargs ) else : app . register_middleware ( future . middleware ) for future in self . exceptions : app . exception ( * future . args , ** future . kwargs ) ( future . handler ) for future in self . statics : uri = url_prefix + future . uri if url_prefix else future . uri app . static ( uri , future . file_or_directory , * future . args , ** future . kwargs ) for event , listeners in self . listeners . items ( ) : for listener in listeners : app . listener ( event ) ( listener )
Register the blueprint to the sanic app.

        :param app: Instance of :class:`sanic.app.Sanic` class
        :param options: Options to be used while registering the
            blueprint into the app.
            *url_prefix* - URL Prefix to override the blueprint prefix