All checks were successful
python-syntax / syntax-check (push) Successful in 6s
41 lines
941 B
Python
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()
|