RaspberryPi4b/SourceCode-NAS-Olivito_Gian...

19 lines
559 B
Python
Raw Normal View History

2024-12-20 13:28:04 +01:00
# 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()