diff --git a/server.py b/server.py index 54ff3c5..c781de2 100644 --- a/server.py +++ b/server.py @@ -602,14 +602,18 @@ if __name__ == '__main__': print("=" * 50) print("🎧 TECHDJ PRO - DUAL PORT ARCHITECTURE") print("=" * 50) - print("👉 DJ PANEL: http://localhost:5000") - print("👉 LISTEN PAGE: http://localhost:5001") + # Ports from environment or defaults + dj_port = int(os.environ.get('DJ_PORT', 5000)) + listen_port = int(os.environ.get('LISTEN_PORT', 5001)) + + print(f"👉 DJ PANEL API: http://0.0.0.0:{dj_port}") + print(f"👉 LISTEN PAGE: http://0.0.0.0:{listen_port}") print("=" * 50) # Audio engine DISABLED - print("✅ Local Radio server ready") + print(f"✅ Local Radio server ready on ports {dj_port} & {listen_port}") # Run both servers using eventlet's spawn eventlet.spawn(_listener_count_sync_loop) - eventlet.spawn(dj_socketio.run, dj_app, host='0.0.0.0', port=5000, debug=False) - listener_socketio.run(listener_app, host='0.0.0.0', port=5001, debug=False) + eventlet.spawn(dj_socketio.run, dj_app, host='0.0.0.0', port=dj_port, debug=False) + listener_socketio.run(listener_app, host='0.0.0.0', port=listen_port, debug=False) diff --git a/techdj_qt.py b/techdj_qt.py index afd057d..ed14894 100644 --- a/techdj_qt.py +++ b/techdj_qt.py @@ -944,7 +944,7 @@ class TechDJMainWindow(QMainWindow): def __init__(self): super().__init__() - self.server_url = "http://localhost:5000" + self.server_url = "http://54.37.246.24:5000" self.cache_dir = Path.home() / ".techdj_cache" self.cache_dir.mkdir(exist_ok=True) @@ -1575,6 +1575,33 @@ class TechDJMainWindow(QMainWindow): """) layout.addWidget(self.glow_slider) + # Server URL configuration + layout.addWidget(QLabel("")) # Spacer + server_title = QLabel("📡 SERVER CONFIGURATION") + server_title.setStyleSheet(f""" + font-family: 'Orbitron'; + font-size: 14px; + font-weight: bold; + color: rgb({SECONDARY_MAGENTA.red()}, {SECONDARY_MAGENTA.green()}, {SECONDARY_MAGENTA.blue()}); + """) + layout.addWidget(server_title) + + server_url_label = QLabel("🔗 Server API URL (e.g. http://localhost:5000)") + server_url_label.setStyleSheet("color: #e0e0e0; font-size: 13px;") + layout.addWidget(server_url_label) + + self.server_url_input = QLineEdit(self.server_url) + self.server_url_input.setStyleSheet(""" + background: rgba(0, 0, 0, 0.4); + border: 1px solid #444; + color: cyan; + padding: 5px; + font-family: 'Rajdhani'; + border-radius: 4px; + """) + self.server_url_input.textChanged.connect(self.on_server_url_change) + layout.addWidget(self.server_url_input) + layout.addStretch() # Position panel @@ -1589,6 +1616,7 @@ class TechDJMainWindow(QMainWindow): data = json.load(f) self.local_folder = data.get('local_folder') self.library_mode = data.get('library_mode', 'server') + self.server_url = data.get('server_url', self.server_url) except Exception as e: print(f"Error loading settings: {e}") @@ -1599,7 +1627,8 @@ class TechDJMainWindow(QMainWindow): with open(settings_path, 'w') as f: json.dump({ 'local_folder': self.local_folder, - 'library_mode': self.library_mode + 'library_mode': self.library_mode, + 'server_url': self.server_url }, f) except Exception as e: print(f"Error saving settings: {e}") @@ -1633,6 +1662,19 @@ class TechDJMainWindow(QMainWindow): self.update_library_list() self.save_settings() + def on_server_url_change(self, text): + """Update server URL and save""" + self.server_url = text + self.save_settings() + + # Debounce the refresh to avoid spamming while typing + if not hasattr(self, '_refresh_timer'): + self._refresh_timer = QTimer() + self._refresh_timer.timeout.connect(self.fetch_library) + self._refresh_timer.setSingleShot(True) + + self._refresh_timer.start(1500) # Refresh library 1.5s after typing stops + def scan_local_library(self): """Scan local folder for audio files""" if not self.local_folder: