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
Paul Wähner 1c03cab457
All checks were successful
python-syntax / syntax-check (push) Successful in 6s
refactor: simplify to see/interact/exec and split server modules
2026-05-03 20:07:12 +02:00

41 lines
941 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():
health = requests.get(f"{BASE_URL}/health", headers=headers, timeout=10)
health.raise_for_status()
print("health:", health.json()["data"])
see = requests.post(
f"{BASE_URL}/see",
headers=headers,
json={
"screen": SCREEN,
"with_grid": True,
"grid_rows": 12,
"grid_cols": 12,
"image_format": "jpeg",
"jpeg_quality": 70,
},
timeout=30,
)
see.raise_for_status()
payload = see.json()["data"]
print("region:", payload["meta"]["region"])
print("grid:", payload["meta"].get("grid", {}))
if __name__ == "__main__":
main()