Skip to content

Commit fa156de

Browse files
authored
Merge pull request larymak#143 from Euphoria99/main
random-quote-generator
2 parents a679e85 + 6aeebcd commit fa156de

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

RandomQuoteGenerator/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Packages Used
2+
3+
```
4+
pip install requests
5+
```
6+
7+
API used : Quote Garden

RandomQuoteGenerator/random-quote.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import requests
2+
3+
4+
## function that gets the random quote
5+
def get_random_quote():
6+
try:
7+
## making the get request
8+
response = requests.get("https://quote-garden.herokuapp.com/api/v3/quotes/random")
9+
if response.status_code == 200:
10+
## extracting the core data
11+
json_data = response.json()
12+
data = json_data['data']
13+
14+
## getting the quote from the data
15+
print(data[0]['quoteText'])
16+
else:
17+
print("Error while getting quote")
18+
except:
19+
print("Something went wrong! Try Again!")
20+
21+
22+
get_random_quote()

0 commit comments

Comments
 (0)