-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
def error_response(status, message): | ||
""" | ||
Custom error response | ||
Args: | ||
status ([string]): [status message -> 404 not found, 500 server error, 400 bad request, etc] | ||
message ([string]): [what error message do you want to show to the end user?] | ||
Returns: | ||
[response]: [Returns a dictionary of status, and message] | ||
""" | ||
|
||
payload = { | ||
"status": status, | ||
"message": message | ||
} | ||
return payload | ||
|
||
|
||
def success_response(status, message, data): | ||
""" | ||
Custom success response | ||
Args: | ||
status ([string]): [status message -> 201 created, 200 ok, 202 accepted, etc] | ||
message ([string]): [what message do you want to show to the end user?] | ||
data ([dict]): [serialized data from the server side] | ||
Returns: | ||
[response]: [Returns a dictionary of status, message, data of whatever object that was serialized] | ||
""" | ||
|
||
payload = { | ||
"status": status, | ||
"message": message, | ||
"data": data | ||
} | ||
return payload |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters