Skip to content

Commit

Permalink
Used if-else instead of match in http_util
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-possible committed Aug 3, 2023
1 parent 8aa69f3 commit 1173158
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions utils/http_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@ def check_response(response):
"""
Helper function to check the response and print accordingly.
"""
match response.status_code:
case 200:
print("Data Found!")
print_response(response)
case 201:
print("Data Created!")
print_response(response)
case 404:
print("Not found! Please Check!")
case 403:
print("Forbidden! This requires authentication!")
case 500:
print("Server Error!")
status_code = response.status_code
if status_code == 200:
print("Data Found!")
print_response(response)
elif status_code == 201:
print("Data Created!")
print_response(response)
elif status_code == 404:
print("Not found! Please Check!")
elif status_code == 403:
print("Forbidden! This requires authentication!")
elif status_code == 500:
print("Server Error!")
else:
print("Unknown status code:", status_code)


def print_response(response):
"""
Expand Down

0 comments on commit 1173158

Please sign in to comment.