mirror of
https://codeberg.org/hyperreal/get-def
synced 2025-01-18 16:33:45 +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)
|
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()
|
||||||
|
|
||||||
|
@ -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" },
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user