-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
match cpython recv timeout behavior. new httpserver example
- Loading branch information
Showing
2 changed files
with
51 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# SPDX-FileCopyrightText: 2023 Tim C for Adafruit Industries | ||
# SPDX-License-Identifier: MIT | ||
|
||
import board | ||
import digitalio | ||
from adafruit_httpserver import Server, Request, Response | ||
from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K | ||
import adafruit_wiznet5k.adafruit_wiznet5k_socket as socket | ||
|
||
print("Wiznet5k HTTPServer Test") | ||
|
||
# For Adafruit Ethernet FeatherWing | ||
cs = digitalio.DigitalInOut(board.D10) | ||
# For Particle Ethernet FeatherWing | ||
# cs = digitalio.DigitalInOut(board.D5) | ||
spi_bus = board.SPI() | ||
|
||
# Initialize ethernet interface with DHCP | ||
eth = WIZNET5K(spi_bus, cs) | ||
|
||
# set the interface on the socket source | ||
socket.set_interface(eth) | ||
|
||
# initialize the server | ||
server = Server(socket, "/static", debug=True) | ||
|
||
|
||
@server.route("/") | ||
def base(request: Request): | ||
""" | ||
Serve a default static plain text message. | ||
""" | ||
return Response(request, "Hello from the CircuitPython HTTP Server!") | ||
|
||
|
||
server.serve_forever(str(eth.pretty_ip(eth.ip_address))) |