Zenaight commited on
Commit
498f30c
·
verified ·
1 Parent(s): a35eeff

Upload main.py

Browse files
Files changed (1) hide show
  1. main.py +18 -1
main.py CHANGED
@@ -37,7 +37,8 @@ async def forward_to_rumas(b64_str: str):
37
  data = resp.json()
38
  print(f"[RUMAS] ✔ 200 {json.dumps(data)[:300]}…")
39
  body = data
40
- print(f"[RUMAS] ✔ {resp.status_code} {body}")
 
41
 
42
  # OPTIONAL: notify user (comment out if you prefer silent)
43
  wa_id = body.get("wa_id") # supply wa_id if backend echoes it
@@ -50,6 +51,22 @@ async def forward_to_rumas(b64_str: str):
50
  except Exception as e:
51
  print(f"[RUMAS] ✘ error while sending '{short}…' →", e)
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  @app.get("/webhook") # verification
54
  def verify(
55
  hub_mode: str = Query(None, alias="hub.mode"),
 
37
  data = resp.json()
38
  print(f"[RUMAS] ✔ 200 {json.dumps(data)[:300]}…")
39
  body = data
40
+ print(f"[RUMAS] ✔ {resp.status_code}")
41
+ pretty_print_dict(body)
42
 
43
  # OPTIONAL: notify user (comment out if you prefer silent)
44
  wa_id = body.get("wa_id") # supply wa_id if backend echoes it
 
51
  except Exception as e:
52
  print(f"[RUMAS] ✘ error while sending '{short}…' →", e)
53
 
54
+ def pretty_print_dict(d, indent=0):
55
+ for k, v in d.items():
56
+ if isinstance(v, dict):
57
+ print(' ' * indent + f"{k}:")
58
+ pretty_print_dict(v, indent + 2)
59
+ elif isinstance(v, list):
60
+ print(' ' * indent + f"{k}: [")
61
+ for item in v:
62
+ if isinstance(item, dict):
63
+ pretty_print_dict(item, indent + 2)
64
+ else:
65
+ print(' ' * (indent + 2) + str(item))
66
+ print(' ' * indent + "]")
67
+ else:
68
+ print(' ' * indent + f"{k}: {v}")
69
+
70
  @app.get("/webhook") # verification
71
  def verify(
72
  hub_mode: str = Query(None, alias="hub.mode"),