WSGI WebDAV Server
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
-
ModuleNotFoundError: No module named 'wsgidav.dir_browser'
cause This import path was deprecated and moved in WsgiDAV v4.0.0.fixUpdate your import statement from `from wsgidav import dir_browser` or similar to `from wsgidav.frontend import dir_browser`. -
TypeError: WsgiDAVApp() got an unexpected keyword argument 'verbose'
cause Configuration option names changed in v4.0.0.fixThe `verbose` option was renamed. Replace `verbose` with `debug_info` in your configuration dictionary (e.g., `"debug_info": True`). Refer to the v4 documentation for current configuration options. -
FileNotFoundError: [Errno 2] No such file or directory: 'some_path'
cause This typically occurs when `FileSystemProvider` is configured with a path that doesn't exist or isn't accessible to the WsgiDAV process.fixEnsure the directory specified for `FileSystemProvider` (e.g., in `provider_mapping`) exists and the user running WsgiDAV has read/write permissions to it. Create the directory if it's missing.
Warnings
- breaking WsgiDAV v4.0.0 introduced significant breaking changes, dropping Python 2 support and requiring Python 3.6+ (now 3.8+).
- breaking The configuration format changed significantly in v4.0.0, with many options renamed or restructured (e.g., `provider_mapping` to `roots` in some contexts, `verbose` to `debug_info`).
- gotcha By default, `wsgidav` expects a WSGI server to run it. While `wsgidav.server.run_server` provides a simple built-in server (Cheroot), it's not recommended for production.
- deprecated The `wsgidav.dir_browser` module was deprecated and moved to `wsgidav.frontend.dir_browser` in v4.0.0.
Install
-
pip install wsgidav -
pip install wsgidav[server] -
pip install wsgidav[yaml]
Imports
- WsgiDAVApp
from wsgidav import WsgiDAVApp
from wsgidav.wsgidav_app import WsgiDAVApp
- FileSystemProvider
from wsgidav.fs_dav_provider import FileSystemProvider
- run_server
from wsgidav.wsgidav_app import run_server
from wsgidav.server import run_server
Quickstart
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)