diff light_bridge.py @ 25:cee43f550577

add /lightNames
author drewp@bigasterisk.com
date Fri, 02 Feb 2024 20:52:09 -0800
parents e3dbd04dab96
children 32cfefe3155b
line wrap: on
line diff
--- a/light_bridge.py	Fri Feb 02 20:51:48 2024 -0800
+++ b/light_bridge.py	Fri Feb 02 20:52:09 2024 -0800
@@ -29,6 +29,9 @@
     await light.setColor(Color.fromHex(body))
     return JSONResponse(light.to_dict())
 
+async def lightNames(lights: Lights, request: Request) -> JSONResponse:
+    return JSONResponse({'lightNames': lights.allNames()})
+
 
 async def table(lights: Lights, req: Request) -> EventSourceResponse:
 
@@ -52,6 +55,7 @@
     app = Starlette(debug=True,
                     routes=[
                         Route('/api/output', partial(output, lights), methods=['PUT']),
+                        Route('/api/lightNames', partial(lightNames, lights), methods=['GET']),
                         Route('/api/table', partial(table, lights)),
                         Route('/api/graph', StaticGraph(graph)),
                         Route('/api/graph/events', GraphEvents(graph)),