Skip to content

Remove secrets #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions examples/wiznet5k_aio_post.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

from os import getenv
import time
import board
import busio
Expand All @@ -9,12 +10,10 @@
import adafruit_requests
from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K

# Get Adafruit.io details from a secrets.py file
try:
from secrets import secrets
except ImportError:
print("WiFi secrets are kept in secrets.py, please add them there!")
raise
# Get Adafruit IO keys, ensure these are setup in settings.toml
# (visit io.adafruit.com if you need to create an account, or if you need your Adafruit IO key.)
aio_username = getenv("ADAFRUIT_AIO_USERNAME")
aio_key = getenv("ADAFRUIT_AIO_KEY")

cs = DigitalInOut(board.D10)
spi_bus = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
Expand All @@ -34,13 +33,9 @@
feed = "test"
payload = {"value": data}
response = requests.post(
"http://io.adafruit.com/api/v2/"
+ secrets["aio_username"]
+ "/feeds/"
+ feed
+ "/data",
f"http://io.adafruit.com/api/v2/{aio_username}/feeds/{feed}/data",
json=payload,
headers={"X-AIO-KEY": secrets["aio_key"]},
headers={"X-AIO-KEY": aio_key},
)
print(response.json())
response.close()
Expand Down