sigyllly commited on
Commit
fcb1da1
·
verified ·
1 Parent(s): 35f83f2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -40
app.py CHANGED
@@ -1,41 +1,42 @@
1
- from wsgidav.wsgidav_app import WsgiDAVApp
2
- from wsgidav.fs_dav_provider import FilesystemProvider
3
- from cheroot.wsgi import Server as WSGIServer
4
- import os
5
-
6
- # Configuration
7
- HOST = "0.0.0.0" # Listen on all interfaces
8
- PORT = 7860 # Port to run the server on
9
- PATH = "./webauth" # Directory to share via WebDAV
10
-
11
- # Create the webauth directory if it doesn't exist
12
- if not os.path.exists(PATH):
13
- os.makedirs(PATH)
14
- print(f"Created directory: {PATH}")
15
-
16
- # Create a sample test.txt file inside the webauth directory
17
- sample_file_path = os.path.join(PATH, "test.txt")
18
- with open(sample_file_path, "w") as f:
19
- f.write("This is a sample file for testing the WebDAV server.\n")
20
- print(f"Created sample file: {sample_file_path}")
21
-
22
- # Create a FilesystemProvider to serve files from the webauth directory
23
- provider = FilesystemProvider(PATH)
24
-
25
- # Configure the WebDAV app
26
- config = {
27
- "provider_mapping": {
28
- "/": provider, # Map the root URL to the provider
29
- },
30
- "verbose": 1, # Enable verbose logging
31
- }
32
-
33
- # Create the WebDAV app
34
- app = WsgiDAVApp(config)
35
-
36
- # Create the WSGI server
37
- server = WSGIServer((HOST, PORT), app)
38
-
39
- # Start the server
40
- print(f"WebDAV server running on http://{HOST}:{PORT}")
 
41
  server.start()
 
1
+ from wsgidav.wsgidav_app import WsgiDAVApp
2
+ from wsgidav.fs_dav_provider import FilesystemProvider
3
+ from cheroot.wsgi import Server as WSGIServer
4
+ import os
5
+
6
+ # Configuration
7
+ HOST = "0.0.0.0" # Listen on all interfaces
8
+ PORT = 7860 # Port to run the server on
9
+ PATH = "./webauth" # Directory to share via WebDAV
10
+
11
+ # Create the webauth directory if it doesn't exist
12
+ if not os.path.exists(PATH):
13
+ os.makedirs(PATH)
14
+ print(f"Created directory: {PATH}")
15
+
16
+ # Create a sample test.txt file inside the webauth directory
17
+ sample_file_path = os.path.join(PATH, "test.txt")
18
+ with open(sample_file_path, "w") as f:
19
+ f.write("This is a sample file for testing the WebDAV server.\n")
20
+ print(f"Created sample file: {sample_file_path}")
21
+
22
+ # Create a FilesystemProvider to serve files from the webauth directory
23
+ provider = FilesystemProvider(PATH)
24
+
25
+ # Configure the WebDAV app
26
+ config = {
27
+ "provider_mapping": {
28
+ "/": provider, # Map the root URL to the provider
29
+ },
30
+ "http_authenticator": None, # Disable authentication
31
+ "verbose": 1, # Enable verbose logging
32
+ }
33
+
34
+ # Create the WebDAV app
35
+ app = WsgiDAVApp(config)
36
+
37
+ # Create the WSGI server
38
+ server = WSGIServer((HOST, PORT), app)
39
+
40
+ # Start the server
41
+ print(f"WebDAV server running on http://{HOST}:{PORT}")
42
  server.start()