Players get a fast TTL-backed homepage (local profile / Cloudflare D1) with dense UI polish; login unlocks /home without blocking on every OpenDota refresh. Co-authored-by: Cursor <cursoragent@cursor.com>
49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
"""Probe which CF API paths work with Global API Key (no secrets printed)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import urllib.error
|
|
import urllib.request
|
|
|
|
ACCT = "510534f7f6284344aadaf2f5a0794d48"
|
|
PATHS = [
|
|
"/user",
|
|
"/accounts",
|
|
f"/accounts/{ACCT}/d1/database",
|
|
f"/accounts/{ACCT}/queues",
|
|
f"/accounts/{ACCT}/r2/buckets",
|
|
f"/accounts/{ACCT}/pages/projects/climperor-relations",
|
|
]
|
|
|
|
|
|
def main() -> int:
|
|
email = os.environ.get("CLOUDFLARE_EMAIL") or os.environ.get(
|
|
"KEYZOO_ASSET_META_USERNAME"
|
|
)
|
|
key = os.environ.get("CLOUDFLARE_API_KEY") or os.environ.get(
|
|
"KEYZOO_ASSET_SECRET_GLOBAL_API_KEY"
|
|
)
|
|
for path in PATHS:
|
|
req = urllib.request.Request(
|
|
"https://api.cloudflare.com/client/v4" + path,
|
|
headers={
|
|
"X-Auth-Email": email,
|
|
"X-Auth-Key": key,
|
|
"User-Agent": "climperor-probe",
|
|
},
|
|
)
|
|
try:
|
|
with urllib.request.urlopen(req, timeout=40) as resp:
|
|
print(f"{path} -> {resp.status}")
|
|
except urllib.error.HTTPError as e:
|
|
snippet = e.read(80).decode("utf-8", errors="replace").replace("\n", " ")
|
|
print(f"{path} -> HTTP {e.code} {snippet[:60]!r}")
|
|
except Exception as e:
|
|
print(f"{path} -> {type(e).__name__}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|