forked from AWSCC-PUP-DWD/AWSCC-CodeQuest-Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday-19.py
24 lines (21 loc) · 737 Bytes
/
day-19.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import requests
# API endpoint for SpaceX latest launch
api_url = "https://api.spacexdata.com/v4/launches/latest"
# Sending a GET request
response = requests.get(api_url)
# Handling the response
if response.status_code == 200:
# Response content as JSON
data = response.json()
mission_name = data["name"]
date_precision = data["date_precision"]
launch_date_utc = data["date_utc"]
details = data["details"]
cores = data["cores"]
print(f"Mission Name: {mission_name}")
print(f"Launch Date (UTC): {launch_date_utc}")
print(f"Date Precision: {date_precision}")
print(f"Details: {details}")
print(f"Cores: {cores}")
else:
print(f"Request failed with status code: {response.status_code}")