#!/usr/bin/env python3 """probe-endpoints.py -- which served endpoints still answer, and in what shape. Read-only. Prints status, byte length and a short structural head for each path; never prints the credential. Used to fix the listing source for the reverse version-layer audit (job 2829). """ import json import os import sys import urllib.error import urllib.request BASE = "https://solveathome.org/projects/twin-primes" TOK = os.path.join(os.environ.get("LOCALAPPDATA", ""), "solveathome", "credentials", "twin-primes.token") PATHS = sys.argv[1:] or [ "/docs", "/docs/", "/docs/research", "/docs/PUBLICATION.json", "/docs/QUESTIONS.md", "/docs/research/fixed-endpoint-discrepancy.md", "/history/QUESTIONS.md", "/history/OUTCOMES.md", "/history/research/fixed-endpoint-discrepancy.md", "/history", "/corpus", ] def main(): tok = open(TOK, encoding="utf-8").read().strip() for p in PATHS: req = urllib.request.Request(BASE + p, headers={ "Accept": "application/json", "Authorization": "Bearer " + tok, "User-Agent": "sahreq/1.0"}, method="GET") try: with urllib.request.urlopen(req, timeout=60) as r: body = r.read().decode("utf-8", "replace") code = r.status except urllib.error.HTTPError as e: body, code = e.read().decode("utf-8", "replace"), e.code except urllib.error.URLError as e: body, code = json.dumps({"transport_error": str(e)}), 0 head = body[:220].replace("\n", " ") print("%-52s %s %7d %s" % (p, code, len(body), head)) if __name__ == "__main__": main()