Skip to content

Commit ed47ded

Browse files
committed
Initial commit
0 parents  commit ed47ded

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

buildspec.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: 0.2
2+
3+
phases:
4+
install:
5+
runtime-versions:
6+
python: 3.9
7+
commands:
8+
- echo "Installing dependencies..."
9+
- pip install -r requirements.txt
10+
pre_build:
11+
commands:
12+
- echo "Entering pre_build phase..."
13+
build:
14+
commands:
15+
- echo "Running Python script to fetch a random joke..."
16+
- python your_script.py
17+
post_build:
18+
commands:
19+
- echo "Build completed successfully."
20+
21+
artifacts:
22+
files:
23+
- '**/*'

requirements.txt

Whitespace-only changes.

your_script.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import requests
2+
3+
def get_random_joke():
4+
url = "https://official-joke-api.appspot.com/random_joke"
5+
6+
response = requests.get(url)
7+
8+
if response.status_code == 200:
9+
joke = response.json()
10+
setup = joke['setup']
11+
punchline = joke['punchline']
12+
print(f"Joke: {setup}")
13+
print(f"Punchline: {punchline}")
14+
else:
15+
print("Failed to retrieve data")
16+
17+
if __name__ == "__main__":
18+
get_random_joke()

0 commit comments

Comments
 (0)