dotfiles/bin/bin/httpstatus

15 lines
393 B
Python
Executable File

#!/usr/bin/env python3
from http import HTTPStatus
from sys import argv, exit, stderr
if len(argv) == 2:
try:
status = HTTPStatus(int(argv[1]))
print(status.phrase)
print(status.description)
except ValueError:
print("Invalid HTTP status code", file=stderr)
exit(1)
else:
print(f"{argv[0]} [code] to print the name of the HTTP status code")