<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def create_url_adapter(self, request: Optional[BaseRequestWebsocket]) -> Optional[MapAdapter]: """Create and return a URL adapter. This will create the adapter based on the request if present otherwise the app configuration. """

        if request is not None:
            host = request.host
            return self.url_map.bind_to_request(
                request.scheme, host, request.method, request.path, request.query_string,
            )

        if self.config['SERVER_NAME'] is not None:
            return self.url_map.bind(
                self.config['PREFERRED_URL_SCHEME'], self.config['SERVER_NAME'],
            )
        return None