Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ipcam was unuseful name #30

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading