Upload 2 files
Browse files- app.py +41 -0
- requierments.txt +2 -0
app.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|
requierments.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
wsgidav>=4.0.0
|
2 |
+
cheroot>=9.0.0
|