Files
felhom.eu/documentation/audits/rehearsal-2026-10-20/tools/bs_cnt.py
T

12 lines
848 B
Python

#!/usr/bin/python3
"""bs_cnt.py [add NAME] — BookStack through its API: optionally add a page, then list pages and images (B8 A.1.5)."""
import json, os, sys
sys.path.insert(0, "/root/work"); from apps import http
b = "https://wiki.tester4.test"; tid, tsec = os.environ["TOK"].split(":", 1); H = {"Authorization": f"Token {tid}:{tsec}"}
if len(sys.argv) > 2 and sys.argv[1] == "add":
print("add", http("POST", b + "/api/pages", {"book_id": 1, "name": sys.argv[2], "markdown": "élő oldal a mentés után"}, H)[0])
st, out, _ = http("GET", b + "/api/pages?count=100", None, H)
print("pages:", st, sorted(x["name"] for x in json.loads(out).get("data", [])) if st == 200 else out[:200])
st, out, _ = http("GET", b + "/api/image-gallery?count=100", None, H)
print("images:", st, len(json.loads(out).get("data", [])) if st == 200 else out[:200])