This repository has been archived on 2026-05-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
clickthrough/examples/quickstart.py
Space-Banane 775c188732
All checks were successful
python-syntax / syntax-check (push) Successful in 1m33s
Support multi-display screen selection
2026-04-29 21:52:01 +02:00

37 lines
885 B
Python

import os
import requests
BASE_URL = os.getenv("CLICKTHROUGH_URL", "http://127.0.0.1:8123")
TOKEN = os.getenv("CLICKTHROUGH_TOKEN", "")
SCREEN = int(os.getenv("CLICKTHROUGH_SCREEN", "0"))
headers = {}
if TOKEN:
headers["x-clickthrough-token"] = TOKEN
def main():
r = requests.get(f"{BASE_URL}/health", headers=headers, timeout=10)
r.raise_for_status()
print("health:", r.json())
d = requests.get(f"{BASE_URL}/displays", headers=headers, timeout=10)
d.raise_for_status()
print("displays:", d.json().get("displays", []))
s = requests.get(
f"{BASE_URL}/screen",
headers=headers,
params={"screen": SCREEN, "with_grid": True, "grid_rows": 12, "grid_cols": 12},
timeout=30,
)
s.raise_for_status()
payload = s.json()
print("screen meta:", payload.get("meta", {}))
if __name__ == "__main__":
main()