diff options
Diffstat (limited to 'natDay.py')
| -rw-r--r-- | natDay.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/natDay.py b/natDay.py new file mode 100644 index 0000000..c5e384f --- /dev/null +++ b/natDay.py @@ -0,0 +1,20 @@ +import requests +import json +import time +import random + +url = "https://national-api-day.herokuapp.com/api/today" + + +def getNationalDay(): + resp = requests.get(url) + + while resp.status_code != 200: + resp = requests.get(url) + time.sleep(10) + + data = json.loads(resp.text) + holidays = data["holidays"] + index = random.randint(0, len(holidays) - 1) + + return [f"Today's National Day:\n{holidays[index]}\n"] |
