<script>
const getDailyQuote = async () => {
try {
const res = await fetch(
'https://script.google.com/macros/s/AKfycbyU2tuTOsLmynjo7oKCUwT4UAXrvfWZSHgnLDqrtK_e1aY_1HyL2LeyBqn5VscEHL-kVg/exec?action=getQuote&key=gC0aCZdHkFp45OIAQH7qDOL4TaCzeR'
);
if (!res.ok) throw new Error(res.status);
return await res.json();
} catch (err) {
console.error('Error fetching daily quote:', err);
return null;
}
};
// Example usage:
getDailyQuote().then(q => {
if (q) {
console.log(`${q.quote} — ${q.author} (${q.date})`);
}
});
</script>
import requests
def get_daily_quote():
"""Fetches the daily quote from the API."""
url = "https://script.google.com/macros/s/AKfycbyU2tuTOsLmynjo7oKCUwT4UAXrvfWZSHgnLDqrtK_e1aY_1HyL2LeyBqn5VscEHL-kVg/exec"
params = {
"action": "getQuote",
"key": "gC0aCZdHkFp45OIAQH7qDOL4TaCzeR"
}
try:
response = requests.get(url, params=params)
response.raise_for_status() # Raise an exception for bad status codes
quote_data = response.json()
return quote_data
except requests.exceptions.RequestException as e:
print(f"Error fetching daily quote: {e}")
return None
# Example usage:
quote = get_daily_quote()
if quote:
print(f"{quote['quote']} — {quote['author']} ({quote['date']})")