Compare commits
6 commits
main
...
update-thi
| Author | SHA1 | Date | |
|---|---|---|---|
| dc65439632 | |||
| 30488c93e1 | |||
| d851c9a74a | |||
| 1fe1708b86 | |||
| e9442e9457 | |||
| 2c7939bb06 |
13 changed files with 22 additions and 8 deletions
1
circup_requirements.txt
Normal file
1
circup_requirements.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
adafruit_requests==2.0.5
|
||||||
|
|
@ -24,8 +24,12 @@ fi
|
||||||
echo "Found device at $device_path"
|
echo "Found device at $device_path"
|
||||||
|
|
||||||
echo 'Copying application code...'
|
echo 'Copying application code...'
|
||||||
rsync --verbose --recursive --delete --checksum \
|
rsync --verbose --recursive --delete --checksum --times --modify-window=1 \
|
||||||
--include '/._*' --exclude '/.*' \
|
--include '/._*' --exclude '/.*' \
|
||||||
--exclude '/boot_out.txt' --exclude '/settings.toml' \
|
--exclude '/boot_out.txt' --exclude '/settings.toml' --exclude '/lib' \
|
||||||
"$project_directory/src/" "$device_path"
|
"$project_directory/src/" "$device_path"
|
||||||
echo 'Finished copying application code'
|
echo 'Finished copying application code'
|
||||||
|
|
||||||
|
echo 'Installing libraries with circup'
|
||||||
|
circup install --requirement circup_requirements.txt
|
||||||
|
echo 'Finished installing libraries with circup'
|
||||||
|
|
|
||||||
18
src/code.py
18
src/code.py
|
|
@ -7,7 +7,17 @@ import socketpool
|
||||||
import supervisor
|
import supervisor
|
||||||
import wifi
|
import wifi
|
||||||
|
|
||||||
from adafruit_httpserver.server import HTTPServer
|
from adafruit_httpserver.server import Server as HTTPServer
|
||||||
|
from adafruit_httpserver.response import Response
|
||||||
|
|
||||||
|
|
||||||
|
def index(request):
|
||||||
|
u = os.uname()
|
||||||
|
return Response(
|
||||||
|
request,
|
||||||
|
content_type="text/plain",
|
||||||
|
body=f"Hello from {u.machine} running CircuitPython {u.version}!\n",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
|
|
@ -24,7 +34,8 @@ def main() -> None:
|
||||||
host = str(wifi.radio.ipv4_address)
|
host = str(wifi.radio.ipv4_address)
|
||||||
pool = socketpool.SocketPool(wifi.radio)
|
pool = socketpool.SocketPool(wifi.radio)
|
||||||
http_server = HTTPServer(pool)
|
http_server = HTTPServer(pool)
|
||||||
http_server.start(host, port=80, root_path="public_html")
|
http_server.route("/")(index)
|
||||||
|
http_server.start(host, port=80)
|
||||||
|
|
||||||
ssl_context = ssl.create_default_context()
|
ssl_context = ssl.create_default_context()
|
||||||
# The Pico is the server and does not require a certificate from the client, so disable
|
# The Pico is the server and does not require a certificate from the client, so disable
|
||||||
|
|
@ -35,7 +46,8 @@ def main() -> None:
|
||||||
)
|
)
|
||||||
tls_pool = TLSServerSocketPool(pool, ssl_context)
|
tls_pool = TLSServerSocketPool(pool, ssl_context)
|
||||||
https_server = HTTPServer(tls_pool)
|
https_server = HTTPServer(tls_pool)
|
||||||
https_server.start(host, port=443, root_path="public_html")
|
https_server.route("/")(index)
|
||||||
|
https_server.start(host, port=443)
|
||||||
|
|
||||||
print()
|
print()
|
||||||
print("The web server is listening on:")
|
print("The web server is listening on:")
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,3 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<title>Hello world · Raspberry Pi Pico W</title>
|
|
||||||
<p>Hello world from Raspberry Pi Pico W!</p>
|
|
||||||
Loading…
Reference in a new issue