1
0
дзеркало https://tildegit.org/ben/dotfiles.git synced 2025-07-15 17:42:02 +00:00

print desc from httpstatus

This commit is contained in:
Ben Harris 2022-07-29 15:52:59 -04:00
джерело f107c145c4
коміт ed016a7211

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