import requests def get_dad_joke(): print("---Náhodný vtip (icanhazdadjoke.com)---") url = "https://icanhazdadjoke.com/" headers = { "Accept": "application/json", "User-Agent" : "Python example for students" } try: #odelsaní jednoduchého GET požadavku response = requests.get(url, headers=headers) #kontrola žda požadavek proběhl úspěšně response.raise_for_status() data = response.json() print(f"{data['joke']}") #vtip = data["joke"] #print(f"{vtip}") except Exception as e: print(f"chyba:{e}") if __name__ == "__main__": get_dad_joke()