#!/usr/bin/env python3
"""Serves precise.html on :8080 and attacker.html on :8081 so the two pages
are distinct origins (required: one gets Precise, the other Approximate-only).
Binds to 0.0.0.0 so an Android device on the same LAN can reach it; restrict
your network accordingly."""
import http.server
import os
import socketserver
import threading

ROOT = os.path.dirname(os.path.abspath(__file__))

class Handler(http.server.SimpleHTTPRequestHandler):
    def __init__(self, *a, **kw):
        super().__init__(*a, directory=ROOT, **kw)

def serve(port):
    with socketserver.TCPServer(("0.0.0.0", port), Handler) as httpd:
        httpd.allow_reuse_address = True
        print(f"[*] serving {ROOT} on 0.0.0.0:{port}")
        httpd.serve_forever()

if __name__ == "__main__":
    threading.Thread(target=serve, args=(8081,), daemon=True).start()
    serve(8080)
