"""Atlas — local dev server (no-cache).

Plain `python -m http.server` lets the browser cache HTML/CSS/JS, so edits
often don't show up without a hard refresh. This thin wrapper sends
no-store headers on every response, so a normal reload always fetches the
latest files. Usage:  python serve.py [port]   (default port 8000)
"""
from http.server import HTTPServer, SimpleHTTPRequestHandler
import sys


class NoCacheHandler(SimpleHTTPRequestHandler):
    def end_headers(self):
        self.send_header("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0")
        self.send_header("Pragma", "no-cache")
        self.send_header("Expires", "0")
        super().end_headers()


if __name__ == "__main__":
    port = int(sys.argv[1]) if len(sys.argv) > 1 else 8000
    print(f"Serving (no-cache) at http://localhost:{port}/  —  Ctrl+C to stop.")
    HTTPServer(("", port), NoCacheHandler).serve_forever()
