from cheroot import wsgi
from wsgidav.wsgidav_app import WsgiDAVApp

config = {
    "host": "0.0.0.0",
    "port": 8082,
    "mount_path": "/drive",
    "simple_dc" : {
            'user_mapping':{
                "*": True
            },
        },
    "provider_mapping": {
        "/public_drive": "/home/ambagasdowa/Development/api/storage",
      },
    "fs_dav_provider": {
        "shadow_map": {},
        "follow_symlinks": True,
    },
    "dir_browser": {
        "enable": True,  # Render HTML listing for GET requests on collections
        # Add a trailing slash to directory URLs (by generating a 301 redirect):
        "directory_slash": True,
        # List of fnmatch patterns:
        "ignore": [
            ".DS_Store",  # macOS folder meta data
            "._*",  # macOS hidden data files
            "Thumbs.db",  # Windows image previews
        ],
        "icon": True,
        "response_trailer": True,  # Raw HTML code, appended as footer (True: use a default)
        "show_user": True,  # Show authenticated user an realm
        # Send <dm:mount> response if request URL contains '?davmount' (rfc4709)
        "davmount": True,
        # Add 'Mount' link at the top
        "davmount_links": False,
        "ms_sharepoint_support": True,  # Invoke MS Office documents for editing using WebDAV
        "libre_office_support": True,  # Invoke Libre Office documents for editing using WebDAV
        # The path to the directory that contains template.html and associated assets.
        # The default is the htdocs directory within the dir_browser directory.
        #"htdocs_path": '/home/ambagasdowa/storage/assets',
        "htdocs_path": None,
    },
    "verbose": 3,
  }
app = WsgiDAVApp(config)

server_args = {
    "bind_addr": (config["host"], config["port"]),
    "wsgi_app": app,
}
server = wsgi.Server(**server_args)

try:
    server.start()
except KeyboardInterrupt:
    print("Received Ctrl-C: stopping...")
finally:
    server.stop()
