print desc from httpstatus

master
Ben Harris 2022-07-29 15:52:59 -04:00
parent f107c145c4
commit ed016a7211
1 changed files with 4 additions and 2 deletions

View File

@ -4,9 +4,11 @@ from sys import argv, exit, stderr
if len(argv) == 2:
try:
print(HTTPStatus(int(argv[1])).name.title().replace("_", " "))
status = HTTPStatus(int(argv[1]))
print(status.phrase)
print(status.description)
except ValueError:
print("Not a valid HTTP status code", file=stderr)
print("Invalid HTTP status code", file=stderr)
exit(1)
else:
print(f"{argv[0]} [code] to print the name of the HTTP status code")