Skip to content

Commit

Permalink
Rename examples & tweak slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
jepler committed Feb 22, 2024
1 parent e14f2ce commit bd51336
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions examples/ipcam/code.py → examples/web_camera/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@
pycam.camera.quality = 6

server = Server(socketpool.SocketPool(wifi.radio))
PORT = 81
if wifi.radio.ipv4_address:
# use alt port if web workflow enabled
port = 8080
else:
# connect to wifi and use standard http port otherwise
wifi.radio.connect(os.getenv("WIFI_SSID"), os.getenv("WIFI_PASSWORD"))
port = 80

BOUNDARY = b"FRAME" + binascii.hexlify(os.urandom(8))


Expand Down Expand Up @@ -51,7 +58,7 @@ def body():


async def poll(interval):
server.start(str(wifi.radio.ipv4_address), port=PORT)
server.start(str(wifi.radio.ipv4_address), port=port)
while True:
try:
server.poll()
Expand All @@ -65,6 +72,6 @@ async def main():
await asyncio.gather(poll_task)


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

asyncio.run(main())
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,5 @@ def property_common(obj, request):
return JSONResponse(request, {"error": str(exc)}, status=BAD_REQUEST_400)


pycam.display_message(f"{wifi.radio.ipv4_address}:{port}/", scale=2)
server.serve_forever(str(wifi.radio.ipv4_address), port)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit bd51336

Please sign in to comment.