fix: check for 404 status

This commit is contained in:
Jeffrey Serio 2024-12-29 23:57:03 -06:00
parent b46573589c
commit ca9f044eaf
2 changed files with 4 additions and 3 deletions

View File

@ -30,6 +30,9 @@ def main():
response = requests.get(word_url, timeout=60) response = requests.get(word_url, timeout=60)
if response.status_code == 404:
exit("Sorry, we couldn't find definitions for the word you were looking for.")
word = response.json()[0].get("word") word = response.json()[0].get("word")
phonetics = response.json()[0].get("phonetics") phonetics = response.json()[0].get("phonetics")
@ -56,8 +59,6 @@ def main():
console = Console(width=100) console = Console(width=100)
print() print()
console.rule()
print()
print(" :arrow_forward: ", Text(word, style="bold red", justify="center")) print(" :arrow_forward: ", Text(word, style="bold red", justify="center"))
print() print()

View File

@ -1,6 +1,6 @@
[project] [project]
name = "get-def" name = "get-def"
version = "0.1" version = "0.2"
authors = [ authors = [
{ name="Jeffrey Serio", email="hyperreal@fedoraproject.org" }, { name="Jeffrey Serio", email="hyperreal@fedoraproject.org" },
] ]