Skip to content

random-quote-generator #143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions RandomQuoteGenerator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Packages Used

```
pip install requests
```

API used : Quote Garden
22 changes: 22 additions & 0 deletions RandomQuoteGenerator/random-quote.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import requests


## function that gets the random quote
def get_random_quote():
try:
## making the get request
response = requests.get("https://quote-garden.herokuapp.com/api/v3/quotes/random")
if response.status_code == 200:
## extracting the core data
json_data = response.json()
data = json_data['data']

## getting the quote from the data
print(data[0]['quoteText'])
else:
print("Error while getting quote")
except:
print("Something went wrong! Try Again!")


get_random_quote()