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.
20 lines
540 B
20 lines
540 B
import requests
|
|
|
|
def get_cnj():
|
|
print("---Náhodný vtip o Chucku Norrisovi---")
|
|
url = "https://api.chucknorris.io/jokes/random"
|
|
|
|
try:
|
|
#odelsaní jednoduchého GET požadavku
|
|
response = requests.get(url)
|
|
#kontrola žda požadavek proběhl úspěšně
|
|
response.raise_for_status()
|
|
data = response.json()
|
|
print(f"{data['value']}")
|
|
#vtip = data["value"]
|
|
#print(f"{vtip}")
|
|
except Exception as e:
|
|
print(f"chyba:{e}")
|
|
|
|
if __name__ == "__main__":
|
|
get_cnj()
|