WSGI WebDAV Server

4.3.3 · active · verified Fri Apr 17

WsgiDAV is a generic and extensible WebDAV server implementation based on WSGI. It allows access to file systems or other storage backends via HTTP, supporting features like locking, versioning, and properties. Currently at version 4.3.3, it receives frequent minor updates with a focus on stability and compatibility.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to set up a basic, anonymous WebDAV server serving a local directory using WsgiDAV programmatically. It creates a temporary directory and a sample file, then starts the server on `http://127.0.0.1:8080`. For production deployments, `WsgiDAVApp` should be integrated with a robust WSGI server like Gunicorn or uWSGI, and authentication should be configured.

import os
from wsgidav.wsgidav_app import WsgiDAVApp
from wsgidav.fs_dav_provider import FileSystemProvider
from wsgidav.server import run_server

# Create a temporary directory for the WebDAV root
dav_root = os.path.join(os.getcwd(), 'my_webdav_root')
os.makedirs(dav_root, exist_ok=True)

# Create a simple file inside the root
with open(os.path.join(dav_root, 'hello.txt'), 'w') as f:
    f.write('Hello, WebDAV!')

config = {
    "host": "127.0.0.1",
    "port": 8080,
    "provider_mapping": {
        "/": FileSystemProvider(dav_root)
    },
    "http_authenticator": {
        "domain_controller": None, # No authentication
        "accept_anonymous": True
    },
    "verbose": 1,
    "dir_browser": {
        "enable": True,
        "remotefs": {
            "enable": True,
            "mount_url": "/",
        }
    }
}

print(f"Starting WsgiDAV server on http://{config['host']}:{config['port']}")
print(f"Serving files from: {dav_root}")
print("Open http://127.0.0.1:8080/ in your browser to test.")

# Run the server. This is a blocking call.
# For production, integrate WsgiDAVApp with a full WSGI server like Gunicorn or uWSGI.
run_server(config)

view raw JSON →