19 lines
559 B
Python
19 lines
559 B
Python
# 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() |