Skip to content

Instantly share code, notes, and snippets.

@faisalburhanudin
Created July 2, 2025 23:48
Show Gist options
  • Select an option

  • Save faisalburhanudin/32a076aaae9e098928e05126eada5420 to your computer and use it in GitHub Desktop.

Select an option

Save faisalburhanudin/32a076aaae9e098928e05126eada5420 to your computer and use it in GitHub Desktop.
Wrapper dax
import os
import requests
import sys
def auth():
if len(sys.argv) < 2:
print("missing brands")
sys.exit(1)
brand = sys.argv[1]
payload = {
"platform": "local-bundle",
"framework": "patchright",
"browser": "chromium",
"brand_name": brand,
"state": {},
}
while True:
resp = requests.post(f"http://127.0.0.1:8000/auth/{brand}", json=payload)
resp_json = resp.json()
status = resp_json.get("status", "")
if status == "FINISHED":
print(resp_json["extract_result"]["bundles"])
break
# replace payload with resp json
# dax need to maintain state this way
payload = resp_json
for choice in resp_json["state"]["prompt"]["choices"]:
for prompt in choice["prompts"]:
name = prompt["name"]
type_ = prompt["type"]
input_value = None
if type_ == "click":
input_value = "true"
if type_ == "text":
# get from environment variable
value = os.getenv(f"{brand.upper()}_{name.upper()}", "")
if not value:
value = input(f"{name}: ")
if value:
input_value = value
else:
print("failed to set input value")
sys.exit(1)
payload["state"]["inputs"][name] = input_value
if __name__ == "__main__":
auth()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment