code: def resource_basename(resource):
      
      if resource.endswith('/'):
           resource = resource[:-1]
      parts = resource.split('/')
      return parts[-1]
docs: Last component of a resource (which always uses '/' as sep).