File tree Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 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+ - ' **/*'
Original file line number Diff line number Diff line change 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 ()
You can’t perform that action at this time.
0 commit comments