You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
584 B

import requests
from termcolor import colored
def get_cnj():
print("--- Nahodný vtip o Chucku Norrisovi ---")
url = "https://api.chucknorris.io/jokes/random"
try:
#odeslání požadavku na "url"
response = requests.get(url)
#čekání na odpovědi od "url"
response.raise_for_status()
#zpracování dat na JSON
data = response.json()
#print(f"RAWDATA:{data}")
print(colored(f"JOKE:{data["value"]}","yellow"))
except Exception as e:
print(f"Chyba:{e}")
if __name__ == "__main__":
get_cnj()