more safe dict
All checks were successful
Meshtastic Map - See local Meshtastic Nodes / deploy (push) Successful in 1s

This commit is contained in:
david 2025-04-13 18:07:22 -07:00
parent 74a48ca352
commit 28d09862c1

9
app.py
View File

@ -19,8 +19,15 @@ def safe_dict(obj):
return [safe_dict(i) for i in obj] return [safe_dict(i) for i in obj]
elif isinstance(obj, bytes): elif isinstance(obj, bytes):
return obj.decode(errors="replace") return obj.decode(errors="replace")
elif hasattr(obj, "__dict__"):
return safe_dict(vars(obj)) # Recursively process custom objects
elif hasattr(obj, "to_dict"):
return safe_dict(obj.to_dict()) # If object has a to_dict() method
else: else:
return obj try:
return str(obj) # Fallback
except Exception:
return None
@app.route("/") @app.route("/")
def index(): def index():