Skip to content

Commit bd51336

Browse files
committed
Rename examples & tweak slightly
1 parent e14f2ce commit bd51336

File tree

6 files changed

+11
-3
lines changed

6 files changed

+11
-3
lines changed

examples/ipcam/code.py renamed to examples/web_camera/code.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@
2222
pycam.camera.quality = 6
2323

2424
server = Server(socketpool.SocketPool(wifi.radio))
25-
PORT = 81
25+
if wifi.radio.ipv4_address:
26+
# use alt port if web workflow enabled
27+
port = 8080
28+
else:
29+
# connect to wifi and use standard http port otherwise
30+
wifi.radio.connect(os.getenv("WIFI_SSID"), os.getenv("WIFI_PASSWORD"))
31+
port = 80
32+
2633
BOUNDARY = b"FRAME" + binascii.hexlify(os.urandom(8))
2734

2835

@@ -51,7 +58,7 @@ def body():
5158

5259

5360
async def poll(interval):
54-
server.start(str(wifi.radio.ipv4_address), port=PORT)
61+
server.start(str(wifi.radio.ipv4_address), port=port)
5562
while True:
5663
try:
5764
server.poll()
@@ -65,6 +72,6 @@ async def main():
6572
await asyncio.gather(poll_task)
6673

6774

68-
pycam.display_message(f"{wifi.radio.ipv4_address}:{PORT}/", scale=2)
75+
pycam.display_message(f"{wifi.radio.ipv4_address}:{port}/", scale=2)
6976

7077
asyncio.run(main())

examples/ipcam2/code.py renamed to examples/web_settings_explorer/code.py

+1
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,5 @@ def property_common(obj, request):
119119
return JSONResponse(request, {"error": str(exc)}, status=BAD_REQUEST_400)
120120

121121

122+
pycam.display_message(f"{wifi.radio.ipv4_address}:{port}/", scale=2)
122123
server.serve_forever(str(wifi.radio.ipv4_address), port)

0 commit comments

Comments
 (0)