Update app.py
Browse files
app.py
CHANGED
|
@@ -43,7 +43,7 @@ def get_random_joke(type: str) -> str:
|
|
| 43 |
url = "https://official-joke-api.appspot.com/types"
|
| 44 |
response = requests.get(url, timeout=20)
|
| 45 |
types = response.json()
|
| 46 |
-
url = f"https://official-joke-api.appspot.com/jokes{f
|
| 47 |
# Send a GET request to the URL with a 20-second timeout
|
| 48 |
response = requests.get(url, timeout=20)
|
| 49 |
response.raise_for_status() # Raise an exception for bad status codes
|
|
|
|
| 43 |
url = "https://official-joke-api.appspot.com/types"
|
| 44 |
response = requests.get(url, timeout=20)
|
| 45 |
types = response.json()
|
| 46 |
+
url = f"https://official-joke-api.appspot.com/jokes{f'/{type}' if type and type in types else ''}/random"
|
| 47 |
# Send a GET request to the URL with a 20-second timeout
|
| 48 |
response = requests.get(url, timeout=20)
|
| 49 |
response.raise_for_status() # Raise an exception for bad status codes
|