global handleDir def handleDir(env): filePath = env["fPath"] simpleResponse( env["self"].connection,"200 OK",{ "Content-Type": "text/html; charset=UTF-8", "Accept-Ranges": "none", "Date": env["requestTimeFormatted"] } ) dirList = [] fileList = [] with fileLock: for root,dirs,files in os.walk(filePath): for file in dirs: dirList.append(p(root,file).replace(filePath + os.path.sep,"",1).replace(os.path.sep,"/") + "/") for file in files: fileList.append(p(root,file).replace(filePath + os.path.sep,"",1).replace(os.path.sep,"/")) break dirList.sort(key=str.lower) fileList.sort(key=str.lower) env["self"].connection.sendall(('''\ ''' +html.escape(env["lPath"])+ ''' ''').encode("utf-8")) env["self"].connection.sendall(('''..
\n''').encode("utf-8")) for l in [dirList,fileList]: for lfile in l: env["self"].connection.sendall(('''''' +html.escape(lfile)+ '''
\n''').encode("utf-8")) env["self"].connection.sendall(('''\ ''').encode("utf-8")) fileHandlers[".d"] = handleDir