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

24 lines
564 B
Python

# SPDX-FileCopyrightText: 2022 Dan Halbert for Adafruit Industries, Michał Pokusa
#
# SPDX-License-Identifier: Unlicense
import socketpool
import wifi
from adafruit_httpserver import FileResponse, Request, Server
pool = socketpool.SocketPool(wifi.radio)
server = Server(pool, "/default-static-folder", debug=True)
@server.route("/home")
def home(request: Request):
"""
Serves the file /other-static-folder/home.html.
"""
return FileResponse(request, "home.html", "/other-static-folder")
server.serve_forever(str(wifi.radio.ipv4_address))