serve only app files, move certs out of app folder
Hunter
Saturday, November 7th, 2026 at 12:32 AM
39 CERT_HTTP_PORT = 8001 # preferred; falls back to the next free port
40 HTTPS_PORT = 8443 # preferred; falls back to the next free port
41 SCRIPT_DIR = Path(__file__).parent.absolute()
-CERT_DIR = SCRIPT_DIR / ".https_certs"
42 +CERT_DIR = Path.home() / ".mixapps" / "https_certs"
43 CERT_FILE = CERT_DIR / "cert.pem"
44 KEY_FILE = CERT_DIR / "key.pem"
45 MANIFEST_FILE = SCRIPT_DIR / "manifest.json"
23 MIX_DIR = SCRIPT_DIR / "mix"
24 TRACKS_PATH = MIX_DIR / "tracks.json"
25
26 +PUBLIC_FILES = {"index.html", "manifest.json", "service-worker.js"}
27 +PUBLIC_DIRS = {"resources", "mix"}
28 +
29 SUPPORTED_UPLOAD_EXTENSIONS = ('.mp3', '.m4a', '.ogg', '.flac', '.wav')
30 MAX_UPLOAD_BYTES = 200 * 1024 * 1024 # 200 MB per request
31
245
246 return super().do_GET()
247
248 + def _is_public(self, fs_path):
249 + parts = Path(fs_path).relative_to(self.directory).parts
250 + if not parts:
251 + return True
252 + if any(part.startswith('.') for part in parts):
253 + return False
254 + if len(parts) == 1:
255 + return parts[0] in PUBLIC_FILES
256 + name = parts[-1].lower()
257 + return parts[0] in PUBLIC_DIRS and name != 'readme.md' and not name.endswith('.uploading')
258 +
259 + def send_head(self):
260 + if not self._is_public(self.translate_path(self.path)):
261 + self.send_error(404)
262 + return None
263 + return super().send_head()
264 +
265 + def list_directory(self, path):
266 + self.send_error(404)
267 + return None
268 +
269 def _serve_sse(self):
270 """Server-Sent Events stream of tracks.json changes."""
271 self.send_response(200)