#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Smoke https://nomadro.com work pages + API (no PowerShell curl alias).""" from __future__ import annotations import json import sys import urllib.error import urllib.request sys.stdout.reconfigure(encoding="utf-8", errors="replace", line_buffering=True) BASE = "https://nomadro.com" PATHS = [ "/social/work", "/social/work/boards", "/social/work/pads", "/api/work/v1/health", "/api/work/v1/boards", "/api/work/v1/projects", "/api/work/v1/pads", ] def fetch(path: str) -> tuple[int, str]: req = urllib.request.Request( BASE + path, headers={"User-Agent": "nomadro-work-smoke/1.0", "Accept": "*/*"}, method="GET", ) try: with urllib.request.urlopen(req, timeout=20) as res: body = res.read().decode("utf-8", "replace") return res.status, body except urllib.error.HTTPError as e: return e.code, e.read().decode("utf-8", "replace") except Exception as e: return 0, str(e) def main() -> int: bad = 0 for path in PATHS: code, body = fetch(path) preview = body.replace("\n", " ")[:160] print(f"{code} {path} {preview}") if code != 200: bad += 1 continue if path.startswith("/api/"): try: data = json.loads(body) except json.JSONDecodeError: print(" ! not json") bad += 1 continue if data.get("ok") is not True: print(" ! ok!=true", data.keys()) bad += 1 elif "Nomadro Work" not in body and "进入看板" not in body and "看板" not in body: # boards/pads pages may omit hero copy; accept any 200 HTML if "" not in body and "