more safe dict
All checks were successful
Meshtastic Map - See local Meshtastic Nodes / deploy (push) Successful in 1s
All checks were successful
Meshtastic Map - See local Meshtastic Nodes / deploy (push) Successful in 1s
This commit is contained in:
parent
74a48ca352
commit
28d09862c1
9
app.py
9
app.py
@ -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():
|
||||||
|
Loading…
Reference in New Issue
Block a user