Gianpaolo Macario
commited on
Commit
·
b502aea
1
Parent(s):
4adaee1
docs(app): improve get_dad_joke docstring
Browse files
app.py
CHANGED
@@ -19,13 +19,18 @@ def greet(name: str) -> str:
|
|
19 |
def get_dad_joke():
|
20 |
"""
|
21 |
Fetches a random dad joke from the icanhazdadjoke.com API.
|
22 |
-
|
|
|
23 |
with appropriate headers to receive JSON response.
|
|
|
|
|
|
|
24 |
Returns:
|
25 |
str: A random dad joke if successful, otherwise returns an error message.
|
26 |
- Success: Returns the joke text
|
27 |
- Failure: Returns "Failed to retrieve a joke." if the API request fails
|
28 |
- No joke: Returns "No joke found." if the API response doesn't contain a joke
|
|
|
29 |
Requires:
|
30 |
requests: The requests library must be imported to make HTTP requests
|
31 |
"""
|
|
|
19 |
def get_dad_joke():
|
20 |
"""
|
21 |
Fetches a random dad joke from the icanhazdadjoke.com API.
|
22 |
+
|
23 |
+
The function makes an HTTP GET request to the <https://icanhazdadjoke.com/> API
|
24 |
with appropriate headers to receive JSON response.
|
25 |
+
|
26 |
+
Args:
|
27 |
+
None
|
28 |
Returns:
|
29 |
str: A random dad joke if successful, otherwise returns an error message.
|
30 |
- Success: Returns the joke text
|
31 |
- Failure: Returns "Failed to retrieve a joke." if the API request fails
|
32 |
- No joke: Returns "No joke found." if the API response doesn't contain a joke
|
33 |
+
|
34 |
Requires:
|
35 |
requests: The requests library must be imported to make HTTP requests
|
36 |
"""
|