Skip to content

Commit 18a3fc5

Browse files
authored
PyPortal_AirQuality: use settings.toml for AIRNOW_TOKEN
1 parent 76cd05b commit 18a3fc5

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

  • PyPortal/PyPortal_AirQuality

PyPortal/PyPortal_AirQuality/code.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,19 @@
77
the number of followers... and display it on a screen!
88
if you can find something that spits out JSON data, we can display it
99
"""
10+
import os
1011
import time
1112
import board
1213
from adafruit_pyportal import PyPortal
1314

14-
# Get wifi details and more from a secrets.py file
15-
try:
16-
from secrets import secrets
17-
except ImportError:
18-
print("WiFi secrets are kept in secrets.py, please add them there!")
19-
raise
20-
2115
# Change this to your zip code, not all locations have AQI data. Check
2216
# https://airnow.gov/ to see if there's data available!
2317
LOCATION = "90210"
2418

2519
# Set up where we'll be fetching data from
2620
DATA_SOURCE = "http://www.airnowapi.org/aq/forecast/zipCode/?format=application/json"
2721
# You'll need to get a token from airnow.gov, looks like '4d36e978-e325-11cec1-08002be10318'
28-
DATA_SOURCE += "&zipCode="+LOCATION+"&API_KEY="+secrets['airnow_token']
22+
DATA_SOURCE += "&zipCode="+LOCATION+"&API_KEY="+os.getenv("AIRNOW_TOKEN")
2923
DATA_LOCATION = [1, "AQI"]
3024

3125
# the current working directory (where this file is)

0 commit comments

Comments
 (0)