code: def etag(func):
      
      @functools.wraps(func)
      def wrapped(*args, **kwargs):
          """Call the view function and generate an ETag value, checking the
          headers to determine what response to send."""
          # only for HEAD and GET requests
          assert request.method in ['HEAD', 'GET'],\
              '@etag is only supported for GET requests'
          response = func(*args, **kwargs)
          response = make_response(response)
          etag_value = '"' + hashlib.md5(response.get_data()).hexdigest() + '"'
          response.headers['ETag'] = etag_value
          if_match = request.headers.get('If-Match')
          if_none_match = request.headers.get('If-None-Match')
          if if_match:
              etag_list = [tag.strip() for tag in if_match.split(',')]
              if etag_value not in etag_list and '*' not in etag_list:
                  response = precondition_failed()
          elif if_none_match:
              etag_list = [tag.strip() for tag in if_none_match.split(',')]
              if etag_value in etag_list or '*' in etag_list:
                  response = not_modified()
          return response
      return wrapped
docs: Return a decorator that generates proper ETag values for a response.
  
      :param func: view function