Mercurial > code > home > repos > light-bridge
comparison light_bridge.py @ 5:7eeda7f4f9cd
spell it to_dict, for compat with DataClassJsonMixin
author | drewp@bigasterisk.com |
---|---|
date | Sun, 28 Jan 2024 16:01:43 -0800 |
parents | c6fd04e07db0 |
children | fc8ed0efcd72 |
comparison
equal
deleted
inserted
replaced
4:e8e4fd6d5619 | 5:7eeda7f4f9cd |
---|---|
25 log = logging.getLogger() | 25 log = logging.getLogger() |
26 | 26 |
27 | 27 |
28 async def output(lights: Lights, request: Request) -> JSONResponse: | 28 async def output(lights: Lights, request: Request) -> JSONResponse: |
29 light = lights.byName(request.query_params['light']) | 29 light = lights.byName(request.query_params['light']) |
30 return JSONResponse(light.to_js()) | 30 return JSONResponse(light.to_dict()) |
31 | 31 |
32 | 32 |
33 async def table(lights: Lights, req: Request) -> EventSourceResponse: | 33 async def table(lights: Lights, req: Request) -> EventSourceResponse: |
34 | 34 |
35 async def g(): | 35 async def g(): |
36 async for ping in lights.changes(): | 36 async for ping in lights.changes(): |
37 yield json.dumps({'now': time.time()} | lights.to_js()) | 37 yield json.dumps({'now': time.time()} | lights.to_dict()) |
38 | 38 |
39 return EventSourceResponse(g()) | 39 return EventSourceResponse(g()) |
40 | 40 |
41 | 41 |
42 def main(): | 42 def main(): |