diff --git a/examples/imageload_from_web.py b/examples/imageload_from_web.py index 9a873a8..79c78dd 100644 --- a/examples/imageload_from_web.py +++ b/examples/imageload_from_web.py @@ -5,34 +5,32 @@ adafruit_requests using BytesIO """ -import ssl from io import BytesIO +from os import getenv +import adafruit_connection_manager import adafruit_requests as requests import board import displayio -import socketpool import wifi import adafruit_imageload -# Get wifi details and more 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 WiFi details, ensure these are setup in settings.toml +ssid = getenv("CIRCUITPY_WIFI_SSID") +password = getenv("CIRCUITPY_WIFI_PASSWORD") -wifi.radio.connect(secrets["ssid"], secrets["password"]) +wifi.radio.connect(ssid, password) print("My IP address is", wifi.radio.ipv4_address) -socket = socketpool.SocketPool(wifi.radio) -https = requests.Session(socket, ssl.create_default_context()) +pool = adafruit_connection_manager.get_radio_socketpool(wifi.radio) +ssl_context = adafruit_connection_manager.get_radio_ssl_context(wifi.radio) +https = requests.Session(pool, ssl_context) url = "https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_ImageLoad/main/examples/images/4bit.bmp" -print("Fetching text from %s" % url) +print(f"Fetching text from {url}") response = https.get(url) print("GET complete") pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy