From 3c1b8e10bdfeb7888fd88f7421cafdf935534c45 Mon Sep 17 00:00:00 2001 From: Neradoc Date: Sun, 23 Mar 2025 17:19:33 +0100 Subject: [PATCH 1/4] enable running on platforms without ssl --- adafruit_httpserver/server.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/adafruit_httpserver/server.py b/adafruit_httpserver/server.py index 992eae5..9e7f2ce 100644 --- a/adafruit_httpserver/server.py +++ b/adafruit_httpserver/server.py @@ -34,8 +34,20 @@ from .route import Route from .status import BAD_REQUEST_400, FORBIDDEN_403, NOT_FOUND_404, UNAUTHORIZED_401 -if implementation.name != "circuitpython": - from ssl import CERT_NONE, Purpose, SSLError +try: + from ssl import SSLContext, create_default_context + + try: # ssl imports for C python + from ssl import ( + CERT_NONE, + Purpose, + SSLError, + ) + except ImportError: + pass + SSL_AVAILABLE = True +except ImportError: + SSL_AVAILABLE = False NO_REQUEST = "no_request" @@ -129,6 +141,8 @@ def __init__( self.https = https if https: + if not SSL_AVAILABLE: + raise NotImplementedError("SSL not available on this platform") self._validate_https_cert_provided(certfile, keyfile) self._ssl_context = self._create_ssl_context(certfile, keyfile) else: From 9ed25b875e4fb1164db1ecadc5079fa7b2dbca89 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 24 Jun 2025 13:01:59 -0400 Subject: [PATCH 2/4] Remove previous `from ssl import` The fix is good, but forgot to remove the non-guarded `from ssl import ...` --- adafruit_httpserver/server.py | 1 - 1 file changed, 1 deletion(-) diff --git a/adafruit_httpserver/server.py b/adafruit_httpserver/server.py index 9e7f2ce..e15a428 100644 --- a/adafruit_httpserver/server.py +++ b/adafruit_httpserver/server.py @@ -13,7 +13,6 @@ pass from errno import EAGAIN, ECONNRESET, ETIMEDOUT -from ssl import SSLContext, create_default_context from sys import implementation from time import monotonic, sleep from traceback import print_exception From 0f654784d818bd66fa5fa05898c77adbe4fcba0d Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 24 Jun 2025 13:10:22 -0400 Subject: [PATCH 3/4] Update Ethernet library usage --- examples/httpserver_simpletest_manual_ethernet.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/httpserver_simpletest_manual_ethernet.py b/examples/httpserver_simpletest_manual_ethernet.py index 5d668b8..80ce1af 100644 --- a/examples/httpserver_simpletest_manual_ethernet.py +++ b/examples/httpserver_simpletest_manual_ethernet.py @@ -2,9 +2,9 @@ # # SPDX-License-Identifier: MIT +import adafruit_connection_manager import board import digitalio -from adafruit_wiznet5k import adafruit_wiznet5k_socket as socket from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K from adafruit_httpserver import Request, Response, Server @@ -20,10 +20,9 @@ # Initialize ethernet interface with DHCP eth = WIZNET5K(spi_bus, cs) -# Set the interface on the socket source -socket.set_interface(eth) +pool = adafruit_connection_manager.get_radio_socketpool(eth) -server = Server(socket, "/static", debug=True) +server = Server(pool, "/static", debug=True) @server.route("/") From d9fb1e5343f6681a4431c888efd42e02052af46b Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 24 Jun 2025 13:22:48 -0400 Subject: [PATCH 4/4] update docs/starting_methods.rst --- docs/starting_methods.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/starting_methods.rst b/docs/starting_methods.rst index 757f966..1b3a289 100644 --- a/docs/starting_methods.rst +++ b/docs/starting_methods.rst @@ -28,13 +28,11 @@ it may not be able to access the internet. Manual Ethernet --------------- -Most of the time, the WiFi will be a preferred way of connecting to the network. -Nevertheless it is also possible to use Ethernet instead of WiFi. -The only difference in usage is related to configuring the ``socket_source`` differently. +Ethernet can also be used to connect to the location network. .. literalinclude:: ../examples/httpserver_simpletest_manual_ethernet.py :caption: examples/httpserver_simpletest_manual_ethernet.py - :emphasize-lines: 7,10,12-24,37 + :emphasize-lines: 11-20 :linenos: Automatic WiFi using ``settings.toml`` 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