diff options
Diffstat (limited to 'app.py')
-rw-r--r-- | app.py | 32 |
1 files changed, 26 insertions, 6 deletions
@@ -1,22 +1,42 @@ -from lifxlan import LifxLAN, BLUE +from random import randint +from lifxlan import LifxLAN from litestar import Litestar, get, post +lifxlan = LifxLAN() + @get("/") -async def index() -> str: - return "Hello, world!" +async def get_index() -> dict[str, str]: + try: + # colors = lifxlan.get_color_all_lights() + lifxlan.set_color_all_lights( + [randint(0, 65535), randint(0, 65535), randint(0, 65535), randint(0, 9000)], + rapid=True, + ) + except Exception as e: + return {"status": "error", "message": str(e)} + + # return {"status": str(colors)} + return {"status": "ok"} @post("/") async def post_index() -> dict[str, str]: - lifxlan = LifxLAN() try: - lifxlan.set_color_all_lights(BLUE, rapid=True) + lifxlan.set_color_all_lights( + [randint(0, 65535), randint(0, 65535), randint(0, 65535), randint(0, 9000)], + rapid=True, + ) except Exception as e: return {"status": "error", "message": str(e)} return {"status": "ok"} -app = Litestar([index, post_index]) +app = Litestar( + [ + get_index, + post_index, + ] +) |