import fcntl,importlib.util,json,os,re,shlex,sys,threading,time,urllib.parse,uuid from http.server import BaseHTTPRequestHandler,ThreadingHTTPServer from pathlib import Path import serial os.umask(0o077) wt=Path.home()/'tmp/k230-recovery-deploy-2026-10-11';d=Path.home()/'tmp/k230-recovery-deploy-board-2026-10-11';e=wt/'docs/evidence/recovery-routes/installed-2026-10-11';mode=sys.argv[1];assert mode in ('candidate','ordinary') spec=importlib.util.spec_from_file_location('rd',wt/'tools/mainline-drm-initrd-shell-trial.py');rd=importlib.util.module_from_spec(spec);spec.loader.exec_module(rd) state=json.loads((d/'state.json').read_text());token=uuid.uuid4().hex class H(BaseHTTPRequestHandler): def do_POST(self): if self.path!='/'+token+'/'+mode+'-runtime.json':self.send_error(404);return size=int(self.headers.get('Content-Length','0')) if not 0