Changed HTTP status code checking to catch success codes other than 200

This commit is contained in:
A.M. Rowsell 2025-02-05 15:30:34 -05:00
parent 30756fc462
commit ec88faa437
Signed by: amr
GPG key ID: 0B6E2D8375CF79A9

View file

@ -26,6 +26,7 @@ log_file_name = r"/app.log"
# Yes, I know you "can't parse HTML with regex", but # Yes, I know you "can't parse HTML with regex", but
# just watch me. # just watch me.
html_filter = re.compile(r"\<\/?([A-Za-z \"\=])*\>") html_filter = re.compile(r"\<\/?([A-Za-z \"\=])*\>")
success_codes = ['200', '201', '202', '203', '204', '205', '206']
def get_description(feed): def get_description(feed):
@ -97,7 +98,7 @@ def main():
r = requests.post( r = requests.post(
hook["webhook"], data=webhook_string, headers=custom_header hook["webhook"], data=webhook_string, headers=custom_header
) )
if r.status_code != "200": if r.status_code not in success_codes:
print( print(
"Error {} while trying to post {}".format( "Error {} while trying to post {}".format(
r.status_code, hook["webhook"] r.status_code, hook["webhook"]