Files
it_school/project2/famousquotes.py
Ionel Andrei Cataon 0528f7c837 updat21
2026-02-12 15:34:02 +02:00

21 lines
531 B
Python

import requests
import os
import sys
API_URL = os.getenv("QUOTE_API_URL", "https://api.quotable.io/random")
def get_quote():
try:
response = requests.get(API_URL, timeout=10)
response.raise_for_status()
data = response.json()
print("-" * 30)
print(f"CITAT: {data['content']}")
print(f"AUTOR: {data['author']}")
print("-" * 30)
except Exception as e:
print(f"Eroare la apelarea API-ului: {e}")
sys.exit(1)
if __name__ == "__main__":
get_quote()