File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 2525# Uncomment the below if you use native CircuitPython modules such as
2626# digitalio, micropython and busio. List the modules you use. Without it, the
2727# autodoc module docs will fail to generate with a warning.
28- # autodoc_mock_imports = ["digitalio", "busio "]
28+ autodoc_mock_imports = ["microcontroller " ]
2929
3030
3131intersphinx_mapping = {
Original file line number Diff line number Diff line change 1+ # SPDX-FileCopyrightText: 2022 Dan Halbert for Adafruit Industries
2+ #
3+ # SPDX-License-Identifier: Unlicense
4+
5+ from secrets import secrets # pylint: disable=no-name-in-module
6+
7+ import microcontroller
8+ import socketpool
9+ import wifi
10+
11+ from adafruit_httpserver import HTTPServer , HTTPResponse
12+
13+ ssid = secrets ["ssid" ]
14+ print ("Connecting to" , ssid )
15+ wifi .radio .connect (ssid , secrets ["password" ])
16+ print ("Connected to" , ssid )
17+ print (f"Listening on http://{ wifi .radio .ipv4_address } :80" )
18+
19+ pool = socketpool .SocketPool (wifi .radio )
20+ server = HTTPServer (pool )
21+
22+
23+ @server .route ("/temperature" )
24+ def base (request ): # pylint: disable=unused-argument
25+ """Return the current temperature"""
26+ # pylint: disable=no-member
27+ return HTTPResponse (body = f"{ str (microcontroller .cpu .temperature )} " )
28+
29+
30+ # Never returns
31+ server .serve_forever (str (wifi .radio .ipv4_address ))
You can’t perform that action at this time.
0 commit comments