added quotes.....
This commit is contained in:
parent
08cc01ca70
commit
f786f29141
2 changed files with 38 additions and 0 deletions
14
api/quote.py
Normal file
14
api/quote.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
import requests
|
||||
import random
|
||||
from util import logging
|
||||
|
||||
def fetch_quote() -> tuple:
|
||||
url = "https://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en"
|
||||
response = requests.get(url)
|
||||
|
||||
if not response.ok:
|
||||
logging.error(f"Failed to access Quotes API: {response.status_code} [{url}]")
|
||||
return ()
|
||||
|
||||
data = response.json()
|
||||
return (data["quoteText"], data["quoteAuthor"])
|
Loading…
Add table
Add a link
Reference in a new issue