Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
|
@@ -19,7 +19,7 @@ def print_human_friendly(payload: Dict[str, Any]) -> None:
|
|
| 19 |
("x_email","π§ x_email (hashed)"),("x_phone","π± x_phone (hashed)"),
|
| 20 |
("x_fn","π§ First Name"),("x_ln","π§ Last Name"),
|
| 21 |
("timestamp","β±οΈ Timestamp"),("client_ua","π₯οΈ Client UA"),
|
| 22 |
-
("
|
| 23 |
]
|
| 24 |
print("\n" + "-"*18 + " π Human-friendly view " + "-"*18)
|
| 25 |
label_pad = 20
|
|
@@ -31,8 +31,10 @@ def print_human_friendly(payload: Dict[str, Any]) -> None:
|
|
| 31 |
print("\nπ§Ί Contents:")
|
| 32 |
for idx, item in enumerate(contents, start=1):
|
| 33 |
if isinstance(item, dict):
|
| 34 |
-
cid=item.get("content_id","-")
|
| 35 |
-
|
|
|
|
|
|
|
| 36 |
print(f" #{idx} β’ ID: {cid} | Name: {name} | Price: {price} | Qty: {qty}")
|
| 37 |
else:
|
| 38 |
print(f" #{idx} β’ {item}")
|
|
@@ -43,6 +45,25 @@ def print_human_friendly(payload: Dict[str, Any]) -> None:
|
|
| 43 |
print(json.dumps(parsed, ensure_ascii=False, indent=2))
|
| 44 |
except Exception:
|
| 45 |
print(str(contents))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
print("-"*60 + "\n")
|
| 47 |
|
| 48 |
async def post_to_gas_raw(raw_body: str, content_type: str) -> Tuple[int, str]:
|
|
|
|
| 19 |
("x_email","π§ x_email (hashed)"),("x_phone","π± x_phone (hashed)"),
|
| 20 |
("x_fn","π§ First Name"),("x_ln","π§ Last Name"),
|
| 21 |
("timestamp","β±οΈ Timestamp"),("client_ua","π₯οΈ Client UA"),
|
| 22 |
+
("user_info","π€ User Info"), ("cart_data","π Cart Data"),
|
| 23 |
]
|
| 24 |
print("\n" + "-"*18 + " π Human-friendly view " + "-"*18)
|
| 25 |
label_pad = 20
|
|
|
|
| 31 |
print("\nπ§Ί Contents:")
|
| 32 |
for idx, item in enumerate(contents, start=1):
|
| 33 |
if isinstance(item, dict):
|
| 34 |
+
cid = item.get("content_id","-")
|
| 35 |
+
name = item.get("content_name","-")
|
| 36 |
+
price = item.get("price","-")
|
| 37 |
+
qty = item.get("quantity","-")
|
| 38 |
print(f" #{idx} β’ ID: {cid} | Name: {name} | Price: {price} | Qty: {qty}")
|
| 39 |
else:
|
| 40 |
print(f" #{idx} β’ {item}")
|
|
|
|
| 45 |
print(json.dumps(parsed, ensure_ascii=False, indent=2))
|
| 46 |
except Exception:
|
| 47 |
print(str(contents))
|
| 48 |
+
|
| 49 |
+
# π€ User Info
|
| 50 |
+
ui = payload.get("user_info") if isinstance(payload, dict) else None
|
| 51 |
+
if ui is not None:
|
| 52 |
+
print("\nπ€ User Info:")
|
| 53 |
+
try:
|
| 54 |
+
print(json.dumps(ui, ensure_ascii=False, indent=2))
|
| 55 |
+
except Exception:
|
| 56 |
+
print(str(ui))
|
| 57 |
+
|
| 58 |
+
# π Cart Data
|
| 59 |
+
cd = payload.get("cart_data") if isinstance(payload, dict) else None
|
| 60 |
+
if cd is not None:
|
| 61 |
+
print("\nπ Cart Data:")
|
| 62 |
+
try:
|
| 63 |
+
print(json.dumps(cd, ensure_ascii=False, indent=2))
|
| 64 |
+
except Exception:
|
| 65 |
+
print(str(cd))
|
| 66 |
+
|
| 67 |
print("-"*60 + "\n")
|
| 68 |
|
| 69 |
async def post_to_gas_raw(raw_body: str, content_type: str) -> Tuple[int, str]:
|