Füge Funktion hinzu, um den RSS-Feed ins httpdocs-Verzeichnis zu kopieren und das Arbeitsverzeichnis für den Server zu wechseln.
This commit is contained in:
@ -246,9 +246,25 @@ Ich spezialisiere mich auf House Music, die mehr als nur Beats bietet – sie er
|
|||||||
import http.server
|
import http.server
|
||||||
import socketserver
|
import socketserver
|
||||||
import os
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
# Wechsle in das Arbeitsverzeichnis
|
# Kopiere den RSS-Feed ins httpdocs-Verzeichnis
|
||||||
original_dir = os.getcwd()
|
if "../httpdocs" in self.audio_dir:
|
||||||
|
httpdocs_path = Path("../httpdocs").resolve()
|
||||||
|
if httpdocs_path.exists():
|
||||||
|
# Kopiere RSS-Feed ins httpdocs-Verzeichnis
|
||||||
|
import shutil
|
||||||
|
source_feed = Path(self.output_file)
|
||||||
|
target_feed = httpdocs_path / self.output_file
|
||||||
|
if source_feed.exists():
|
||||||
|
shutil.copy2(source_feed, target_feed)
|
||||||
|
print(f"📄 RSS-Feed kopiert nach: {target_feed}")
|
||||||
|
|
||||||
|
# Wechsle ins httpdocs-Verzeichnis für den Server
|
||||||
|
os.chdir(httpdocs_path)
|
||||||
|
print(f"📁 Server-Root: {httpdocs_path}")
|
||||||
|
else:
|
||||||
|
print(f"⚠️ httpdocs-Verzeichnis nicht gefunden: {httpdocs_path}")
|
||||||
|
|
||||||
class CustomHandler(http.server.SimpleHTTPRequestHandler):
|
class CustomHandler(http.server.SimpleHTTPRequestHandler):
|
||||||
def end_headers(self):
|
def end_headers(self):
|
||||||
@ -264,7 +280,7 @@ Ich spezialisiere mich auf House Music, die mehr als nur Beats bietet – sie er
|
|||||||
with socketserver.TCPServer(("", port), handler) as httpd:
|
with socketserver.TCPServer(("", port), handler) as httpd:
|
||||||
print(f"🌐 Server läuft auf http://localhost:{port}")
|
print(f"🌐 Server läuft auf http://localhost:{port}")
|
||||||
print(f"📡 RSS-Feed: http://localhost:{port}/{self.output_file}")
|
print(f"📡 RSS-Feed: http://localhost:{port}/{self.output_file}")
|
||||||
print(f"🎵 Audio-Dateien: http://localhost:{port}/{self.audio_dir}/")
|
print(f"🎵 Audio-Dateien: http://localhost:{port}/_audio/")
|
||||||
print("⏹️ Drücke Ctrl+C zum Beenden")
|
print("⏹️ Drücke Ctrl+C zum Beenden")
|
||||||
httpd.serve_forever()
|
httpd.serve_forever()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
Reference in New Issue
Block a user