15 lines
471 B
Python
15 lines
471 B
Python
from typing import Any, Dict, Optional
|
|
|
|
def format_response(success: bool, message: str, data: Optional[Any] = None) -> Dict[str, Any]:
|
|
"""
|
|
Format standard API JSON responses to match client-side expectations.
|
|
Usage Example: return format_response(True, "Data fetched successfully", alumni_list)
|
|
"""
|
|
response = {
|
|
"success": success,
|
|
"message": message
|
|
}
|
|
if data is not None:
|
|
response["data"] = data
|
|
return response
|