summaryrefslogtreecommitdiff
path: root/natDay.py
blob: c5e384fc43d7dd183d323cd7b0f654fc63e929ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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"]