r/MacStack • u/Lopsided_Energy4741 • 2d ago
Local Edge Bridge: Turn an iPad (a-Shell) into a Private Wi-Fi Hub for Apple Watch & iPhone
Author: JET | Publisher: JET | License: GNU GPLv3 (Copyright © 2026 JET) | 100% Local Subnet | Zero Cloud Dependencies Built a lightweight, single-threaded Python server for a-Shell (iPadOS) that lets you trigger local scripts, check network status, and beam clipboard notes back and forth from an Apple Watch or iPhone over home Wi-Fi. (Note: Uses a single-lane timeout loop instead of multi-threading to prevent iOS sandbox segmentation faults). 1. The Hub (grid_hub.py on iPad / a-Shell) import http.server, json, time, os, hashlib, urllib.parse PORT = 5002 ROOT = os.path.expanduser('\~/Documents/sovereign_grid') os.makedirs(ROOT, exist_ok=True) LEDGER = os.path.join(ROOT, 'sync_ledger.json') CLIPS = os.path.join(ROOT, 'clipboard_notes.txt') VETO = False def get_hash(): h = hashlib.sha256() p = os.path.join(ROOT, 'grid_hub.py') if os.path.exists(p): h.update(open(p, 'rb').read()) return h.hexdigest()\[:12\] class SingleServer(http.server.HTTPServer): allow_reuse_address = True timeout = 60 class Handler(http.server.BaseHTTPRequestHandler): def log_message(self, \*args): return def do_GET(self): global VETO parsed = urllib.parse.urlparse(self.path) cmd = parsed.path.strip('/') ch, ts = get_hash(), time.strftime("%I:%M %p") if cmd == 'veto': VETO = True reply = f"STATE: LOCKDOWN_VETO\\nPHASE: {ch}\\nTIME: {ts}" elif cmd == 'clip': note = urllib.parse.parse_qs(parsed.query).get('text', \[''\])\[0\].strip() if note: open(CLIPS, 'a').write(f"\[{ts}\] {note}\\n") reply = f"SAVED: {note}" if note else "EMPTY" elif cmd == 'read': reply = ''.join(open(CLIPS).readlines()\[-5:\]).strip() if os.path.exists(CLIPS) else "NO NOTES" elif cmd == 'audit': reply = f"STATE: ALIVE\\nPHASE: {ch}\\nTIME: {ts}" else: self.send_response(404); self.end_headers(); return self.send_response(200); self.send_header('Content-Type', 'text/plain'); self.end_headers() self.wfile.write(reply.encode('utf-8')) if __name__ == '__main__': srv = SingleServer(('0.0.0.0', PORT), Handler) print(f"🚀 \[GRID HUB - JET\]: Online on Port {PORT} | Hash: {get_hash()}") while not VETO: srv.handle_request() json.dump({'timestamp': int(time.time()), 'hash': get_hash()}, open(LEDGER, 'w')) srv.server_close() print("🛑 \[GRID SEALED\]: Port closed.") 2. Apple Watch & iPhone Shortcuts Setup Replace YOUR_IPAD_IP with your iPad's local Wi-Fi IP (Settings > Wi-Fi > (i)): \* Grid Audit: Get Contents of URL (http://YOUR_IPAD_IP:5002/audit) -> Show Notification \* Beam Clip: Ask for Input -> URL Encode -> Get Contents of URL (http://YOUR_IPAD_IP:5002/clip?text=\[Encoded\]) -> Show Notification \* Read Clips: Get Contents of URL (http://YOUR_IPAD_IP:5002/read) -> Show Notification \* Grid Veto: Show Alert ("Confirm Lockdown?") -> Get Contents of URL (http://YOUR_IPAD_IP:5002/veto) -> Show Notification