code: def websocket(
          self, uri, host=None, strict_slashes=None, subprotocols=None, name=None
      ):
          
          self.enable_websocket()
  
          # Fix case where the user did not prefix the URL with a /
          # and will probably get confused as to why it's not working
          if not uri.startswith("/"):
              uri = "/" + uri
  
          if strict_slashes is None:
              strict_slashes = self.strict_slashes
  
          def response(handler):
              async def websocket_handler(request, *args, **kwargs):
                  request.app = self
                  if not getattr(handler, "__blueprintname__", False):
                      request.endpoint = handler.__name__
                  else:
                      request.endpoint = (
                          getattr(handler, "__blueprintname__", "")
                          + handler.__name__
                      )
                  try:
                      protocol = request.transport.get_protocol()
                  except AttributeError:
                      # On Python3.5 the Transport classes in asyncio do not
                      # have a get_protocol() method as in uvloop
                      protocol = request.transport._protocol
                  ws = await protocol.websocket_handshake(request, subprotocols)
  
                  # schedule the application handler
                  # its future is kept in self.websocket_tasks in case it
                  # needs to be cancelled due to the server being stopped
                  fut = ensure_future(handler(request, ws, *args, **kwargs))
                  self.websocket_tasks.add(fut)
                  try:
                      await fut
                  except (CancelledError, ConnectionClosed):
                      pass
                  finally:
                      self.websocket_tasks.remove(fut)
                  await ws.close()
  
              self.router.add(
                  uri=uri,
                  handler=websocket_handler,
                  methods=frozenset({"GET"}),
                  host=host,
                  strict_slashes=strict_slashes,
                  name=name,
              )
              return handler
  
          return response
docs: Decorate a function to be registered as a websocket route
          :param uri: path of the URL
          :param subprotocols: optional list of str with supported subprotocols
          :param host:
          :return: decorated function