add lil http status code script

This commit is contained in:
Ben Harris 2022-07-29 15:44:02 -04:00
parent 30fc00b49f
commit f107c145c4
1 changed files with 12 additions and 0 deletions

12
bin/bin/httpstatus Executable file
View File

@ -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")