Adafruit_CircuitPython_HTTP.../examples/httpserver_simpletest_manual_ap.py
2025-05-16 16:11:43 +00:00

29 lines
673 B
Python

# SPDX-FileCopyrightText: 2024 Michał Pokusa
#
# SPDX-License-Identifier: Unlicense
import socketpool
import wifi
from adafruit_httpserver import Request, Response, Server
AP_SSID = "..."
AP_PASSWORD = "..."
print("Creating access point...")
wifi.radio.start_ap(ssid=AP_SSID, password=AP_PASSWORD)
print(f"Created access point {AP_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_ap))