Added NASA APOD. Added Config Module
This commit is contained in:
parent
06cd25eb96
commit
d2622e25e8
6 changed files with 83 additions and 15 deletions
15
api/nasa.py
Normal file
15
api/nasa.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
import requests
|
||||
from util import config, logging
|
||||
|
||||
api_key = config.settings["api_keys"]["nasa"]
|
||||
|
||||
def image_of_the_day():
|
||||
url = f"https://api.nasa.gov/planetary/apod?api_key={api_key}"
|
||||
response = requests.get(url)
|
||||
|
||||
if not response.ok:
|
||||
logging.error(f"Failed to fetch Image of the day (NASA API): {response.status_code}")
|
||||
return
|
||||
|
||||
image_link = response.json()["hdurl"]
|
||||
return image_link
|
Loading…
Add table
Add a link
Reference in a new issue