All checks were successful
python-syntax / syntax-check (push) Successful in 7s
40 lines
953 B
Python
40 lines
953 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 ok:", health.json().get("ok"))
|
|
|
|
observe = requests.post(
|
|
f"{BASE_URL}/v2/observe",
|
|
headers=headers,
|
|
params={"screen": SCREEN},
|
|
json={
|
|
"mode": "screen",
|
|
"include_image": False,
|
|
"ocr_mode": "none",
|
|
},
|
|
timeout=20,
|
|
)
|
|
observe.raise_for_status()
|
|
payload = observe.json()["data"]
|
|
print("observation_id:", payload["observation_id"])
|
|
print("region:", payload["region"])
|
|
print("timing_ms:", payload["timing_ms"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|