From 4fca5087eb1be9c50eff8b1948dc0565563268ca Mon Sep 17 00:00:00 2001 From: Stefan Hynek <stefan.hynek@uni-goettingen.de> Date: Thu, 21 Oct 2021 13:34:26 +0200 Subject: [PATCH] feat(main.py): initialize and launch the wsgi server process --- src/main.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/main.py diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..340f7aa --- /dev/null +++ b/src/main.py @@ -0,0 +1,52 @@ +import logging +import os + +from cheroot import wsgi +from wsgidav.wsgidav_app import WsgiDAVApp + +logging.basicConfig(level=logging.DEBUG, + format='%(name)s %(levelname)s %(asctime)s %(message)s') +_logger = logging.getLogger(__name__) +_logger.propagate = True + +# configure the "wsgidav" named logger +tmp_logger = logging.getLogger("wsgidav") +tmp_logger.propagate = True +tmp_logger.setLevel(logging.DEBUG) + + +# Configuration of the WsgiDAVApp. +# https://wsgidav.readthedocs.io/en/latest/user_guide_configure.html +config = { + "host": os.getenv("host"), + "port": int(os.getenv("port")), + "provider_mapping": { + "/": {"provider": "repdav.textgrid_dav_provider.TextgridResourceProvider"}, + }, + "verbose": 1, + "simple_dc": { + "user_mapping": { + "*": { + "user": { + "password": "pass"}} + } + }, + "http_authenticator": { + "domain_controller": "repdav.textgrid_domain_controller.TextgridDC", + "accept_basic": True, # Allow basic authentication, True or False + "accept_digest": False, # Allow digest authentication, True or False + # True (default digest) or False (default basic) + "default_to_digest": False, + # Name of a header field that will be accepted as authorized user + "trusted_auth_header": None, + } +} + +app = WsgiDAVApp(config) + +server_args = { + "bind_addr": (config["host"], config["port"]), + "wsgi_app": app, +} +server = wsgi.Server(**server_args) +server.start() -- GitLab