From f107c145c412025e222802be6f1055f58146f697 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Fri, 29 Jul 2022 15:44:02 -0400 Subject: [PATCH] add lil http status code script --- bin/bin/httpstatus | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 bin/bin/httpstatus diff --git a/bin/bin/httpstatus b/bin/bin/httpstatus new file mode 100755 index 0000000..b0a9470 --- /dev/null +++ b/bin/bin/httpstatus @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 +from http import HTTPStatus +from sys import argv, exit, stderr + +if len(argv) == 2: + try: + print(HTTPStatus(int(argv[1])).name.title().replace("_", " ")) + except ValueError: + print("Not a valid HTTP status code", file=stderr) + exit(1) +else: + print(f"{argv[0]} [code] to print the name of the HTTP status code")