LPX55 commited on
Commit
ba33dfe
·
verified ·
1 Parent(s): 2617b78

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +64 -3
app.py CHANGED
@@ -2,8 +2,19 @@ import os
2
  from cheroot import wsgi
3
  from wsgidav.wsgidav_app import WsgiDAVApp
4
  from wsgidav.fs_dav_provider import FilesystemProvider
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- # Create the files directory and sample.txt
7
  files_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "files")
8
  if not os.path.exists(files_dir):
9
  os.makedirs(files_dir)
@@ -19,11 +30,61 @@ config = {
19
  "provider_mapping": {
20
  "/": FilesystemProvider(files_dir)
21
  },
 
 
 
 
 
 
 
 
 
22
  "http_authenticator": {
23
  "domain_controller": None,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  },
25
- "simple_dc": {"user_mapping": {"*": True}}, # No authentication
26
- "verbose": 1,
27
  }
28
 
29
  # Create the WSGI application
 
2
  from cheroot import wsgi
3
  from wsgidav.wsgidav_app import WsgiDAVApp
4
  from wsgidav.fs_dav_provider import FilesystemProvider
5
+ # from wsgidav.mw.debug_filter import WsgiDavDebugFilter
6
+ from wsgidav.dir_browser import WsgiDavDirBrowser
7
+ from wsgidav.error_printer import ErrorPrinter
8
+ from wsgidav.http_authenticator import HTTPAuthenticator
9
+
10
+ # from wsgidav.mw.impersonator import Impersonator
11
+ from wsgidav.mw.cors import Cors
12
+ from wsgidav.request_resolver import RequestResolver
13
+
14
+ DEFAULT_VERBOSE = 3
15
+ DEFAULT_LOGGER_DATE_FORMAT = "%H:%M:%S"
16
+ DEFAULT_LOGGER_FORMAT = "%(asctime)s.%(msecs)03d - %(levelname)-8s: %(message)s"
17
 
 
18
  files_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "files")
19
  if not os.path.exists(files_dir):
20
  os.makedirs(files_dir)
 
30
  "provider_mapping": {
31
  "/": FilesystemProvider(files_dir)
32
  },
33
+ "middleware_stack": [
34
+ # WsgiDavDebugFilter,
35
+ Cors,
36
+ ErrorPrinter,
37
+ HTTPAuthenticator,
38
+ # Impersonator,
39
+ WsgiDavDirBrowser, # configured under dir_browser option (see below)
40
+ RequestResolver, # this must be the last middleware item
41
+ ],
42
  "http_authenticator": {
43
  "domain_controller": None,
44
+ "accept_basic": True, # Allow basic authentication, True or False
45
+ "accept_digest": True, # Allow digest authentication, True or False
46
+ "default_to_digest": True, # True (default digest) or False (default basic)
47
+ # Name of a header field that will be accepted as authorized user
48
+ "trusted_auth_header": None,
49
+ },
50
+ "simple_dc": {"user_mapping": {
51
+ "*": {
52
+ "user":
53
+ "password": "hunter123",
54
+ "roles": ["editor", "admin"]
55
+ }
56
+ }},
57
+ "verbose": DEFAULT_VERBOSE,
58
+ "logging": {
59
+ "enable": True, # True: activate 'wsgidav' logger (in library mode)
60
+ "logger_date_format": DEFAULT_LOGGER_DATE_FORMAT,
61
+ "logger_format": DEFAULT_LOGGER_FORMAT,
62
+ "enable_loggers": [],
63
+ "debug_methods": [],
64
+ },
65
+ "dir_browser": {
66
+ "enable": True, # Render HTML listing for GET requests on collections
67
+ # Add a trailing slash to directory URLs (by generating a 301 redirect):
68
+ "directory_slash": True,
69
+ # List of fnmatch patterns:
70
+ "ignore": [
71
+ ".DS_Store", # macOS folder meta data
72
+ "._*", # macOS hidden data files
73
+ "Thumbs.db", # Windows image previews
74
+ ],
75
+ "icon": True,
76
+ "response_trailer": True, # Raw HTML code, appended as footer (True: use a default)
77
+ "show_user": True, # Show authenticated user an realm
78
+ # Send <dm:mount> response if request URL contains '?davmount' (rfc4709)
79
+ "davmount": True,
80
+ # Add 'Mount' link at the top
81
+ "davmount_links": False,
82
+ "ms_sharepoint_support": False, # Invoke MS Office documents for editing using WebDAV
83
+ "libre_office_support": False, # Invoke Libre Office documents for editing using WebDAV
84
+ # The path to the directory that contains template.html and associated assets.
85
+ # The default is the htdocs directory within the dir_browser directory.
86
+ "htdocs_path": None,
87
  },
 
 
88
  }
89
 
90
  # Create the WSGI application