30 lines
684 B
Python
30 lines
684 B
Python
# SPDX-FileCopyrightText: 2022 Dan Halbert for Adafruit Industries
|
|
#
|
|
# SPDX-License-Identifier: Unlicense
|
|
|
|
import socketpool
|
|
import wifi
|
|
|
|
from adafruit_httpserver import Request, Response, Server
|
|
|
|
WIFI_SSID = "..."
|
|
WIFI_PASSWORD = "..."
|
|
|
|
print(f"Connecting to {WIFI_SSID}...")
|
|
wifi.radio.connect(WIFI_SSID, WIFI_PASSWORD)
|
|
print(f"Connected to {WIFI_SSID}")
|
|
|
|
pool = socketpool.SocketPool(wifi.radio)
|
|
|
|
server = Server(pool, "/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(wifi.radio.ipv4_address))
|