Update app.py
Browse files
app.py
CHANGED
@@ -1,49 +1,42 @@
|
|
1 |
import os
|
2 |
-
from
|
3 |
-
from wsgidav.
|
4 |
-
from wsgidav.
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
# Create
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
print(f"Starting WebDAV server on http://0.0.0.0:7860/")
|
44 |
-
|
45 |
-
# Start the WebDAV server
|
46 |
-
app.run()
|
47 |
-
|
48 |
-
if __name__ == "__main__":
|
49 |
-
start_webdav_server()
|
|
|
1 |
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)
|
10 |
+
|
11 |
+
# Create a sample.txt file
|
12 |
+
with open(os.path.join(files_dir, "sample.txt"), "w") as f:
|
13 |
+
f.write("This is a sample file for the WebDAV server.")
|
14 |
+
|
15 |
+
print(f"Created 'files' directory with sample.txt at {files_dir}")
|
16 |
+
|
17 |
+
# Configuration
|
18 |
+
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
|
30 |
+
app = WsgiDAVApp(config)
|
31 |
+
|
32 |
+
# Create and start the server
|
33 |
+
server_addr = "0.0.0.0"
|
34 |
+
server_port = 7860
|
35 |
+
server = wsgi.Server((server_addr, server_port), app)
|
36 |
+
|
37 |
+
print(f"Starting WebDAV server at http://{server_addr}:{server_port}")
|
38 |
+
try:
|
39 |
+
server.start()
|
40 |
+
except KeyboardInterrupt:
|
41 |
+
print("Stopping server...")
|
42 |
+
server.stop()
|
|
|
|
|
|
|
|
|
|
|
|
|
|