有没有比这更好的琐碎的Python WebDAV服务器代码片段?

Jac*_*son 1 python webdav

有没有人为一个简单的Python WebDAV服务器有更好的代码片段?下面的代码(这是从一些谷歌的搜索结果中拼凑起来的)出现的Python 2.6下工作,但我不知道是否有人有东西,他们以前也使用过,一点点更多测试,完整.我更喜欢仅限stdlib的代码段而不是第三方软件包.这是为了一些测试代码,所以不必生产值得.

import httplib
import BaseHTTPServer

class WebDAV(BaseHTTPServer.BaseHTTPRequestHandler):
    """
    Ultra-simplistic WebDAV server.
    """
    def do_PUT(self):
        path = os.path.normpath(self.path)
        if os.path.isabs(path):
            path = path[1:]    # safe assumption due to normpath above
        directory = os.path.dirname(path)
        if not os.path.isdir(directory):
            os.makedirs(directory)
        content_length = int(self.headers['Content-Length'])
        with open(path, "w") as f:
            f.write(self.rfile.read(content_length))

        self.send_response(httplib.OK)

def server_main(server_class=BaseHTTPServer.HTTPServer, 
                handler_class=WebDAV):
    server_class(('', 9231), handler_class).serve_forever()
Run Code Online (Sandbox Code Playgroud)

mar*_*r10 5

或者尝试WsgiDAV,它是PyFileServer的重构版本.