From f9e6f5e9e16214aafa8d95c8a806d66554babc0a Mon Sep 17 00:00:00 2001 From: Gianluca Olivito Date: Fri, 20 Dec 2024 13:28:04 +0100 Subject: [PATCH] Initial commit --- ...ceCode-NAS-Olivito_Gianluca_CDS205_HS24.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 SourceCode-NAS-Olivito_Gianluca_CDS205_HS24.py diff --git a/SourceCode-NAS-Olivito_Gianluca_CDS205_HS24.py b/SourceCode-NAS-Olivito_Gianluca_CDS205_HS24.py new file mode 100644 index 0000000..449a0b6 --- /dev/null +++ b/SourceCode-NAS-Olivito_Gianluca_CDS205_HS24.py @@ -0,0 +1,19 @@ +# Import libraries +import http.server +import socketserver + +# Define port and path tho external drive directory +PORT = 8000 +DIRECTORY = "/mnt/mydisk" + +class MyHandler(http.server.SimpleHTTPRequestHandler): + def translatePath(self, path): + # Modifizieren des Standardverhaltens von SimpleHTTPRequestHandler + path = super().translate_path(path) + return path if path.startswith(DIRECTORY) else DIRECTORY + path + +handler = MyHandler +httpd = socketserver.TCPServer(("", PORT), handler) + +print(f"Serving on port {PORT}") +httpd.serve_forever() \ No newline at end of file