diff --git a/app.py b/app.py index b45bf3d..0dabe51 100644 --- a/app.py +++ b/app.py @@ -19,8 +19,15 @@ def safe_dict(obj): return [safe_dict(i) for i in obj] elif isinstance(obj, bytes): 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: - return obj + try: + return str(obj) # Fallback + except Exception: + return None @app.route("/") def index():