def directoryListing(self):
        """
        Return a resource that generates an HTML listing of the
        directory this path represents.

        @return: A resource that renders the directory to HTML.
        @rtype: L{DirectoryLister}
        """
        if _PY3:
            path = self.path
            names = self.listNames()
        else:
            # DirectoryLister works in terms of native strings, so on
            # Python 2, ensure we have a bytes paths for this
            # directory and its contents.  We use the asBytesMode
            # method inherited from FilePath to ensure consistent
            # encoding of the actual path.  This returns a FilePath
            # instance even when called on subclasses, however, so we
            # have to create a new File instance.
            nativeStringPath = self.createSimilarFile(self.asBytesMode().path)
            path = nativeStringPath.path
            names = nativeStringPath.listNames()
        return DirectoryLister(path,
                               names,
                               self.contentTypes,
                               self.contentEncodings,
                               self.defaultType)

        Return a resource that generates an HTML listing of the
        directory this path represents.

        @return: A resource that renders the directory to HTML.
        @rtype: L{DirectoryLister}
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/static.py