adafruit / Adafruit_CircuitPython_PyPortal

CircuitPython driver for Adafruit PyPortal.
MIT License
45 stars 56 forks source link

Refactor to use secrets_data like PortalBase #101

Closed jfurcean closed 3 years ago

jfurcean commented 3 years ago

Refactor to work with the refactor fork of PortalBase to use secrets_data - https://github.com/adafruit/Adafruit_CircuitPython_PortalBase/pull/10

import board
from adafruit_pyportal import PyPortal

# Get wifi details and more from a secrets.py file
try:
    from test_secrets import secrets
except ImportError:
    print("WiFi secrets are kept in secrets.py, please add them there!")
    raise

# Set a data source URL
TEXT_URL = "http://wifitest.adafruit.com/testwifi/index.html"

# Create the PyPortal object
pyportal = PyPortal(url=TEXT_URL, status_neopixel=board.NEOPIXEL,secrets_data = secrets)

# Set display to show REPL
board.DISPLAY.show(None)

# Go get that data
print("Fetching text from", TEXT_URL)
data = pyportal.fetch()

# Print out what we got
print("-" * 40)
print(data)
print("-" * 40)