mirror of
https://codeberg.org/hyperreal/get-def
synced 2025-01-18 08:23:44 +01:00
fix: check for 404 status
This commit is contained in:
parent
b46573589c
commit
ca9f044eaf
@ -30,6 +30,9 @@ def main():
|
||||
|
||||
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")
|
||||
|
||||
phonetics = response.json()[0].get("phonetics")
|
||||
@ -56,8 +59,6 @@ def main():
|
||||
|
||||
console = Console(width=100)
|
||||
print()
|
||||
console.rule()
|
||||
print()
|
||||
print(" :arrow_forward: ", Text(word, style="bold red", justify="center"))
|
||||
print()
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "get-def"
|
||||
version = "0.1"
|
||||
version = "0.2"
|
||||
authors = [
|
||||
{ name="Jeffrey Serio", email="hyperreal@fedoraproject.org" },
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user