diff options
Diffstat (limited to 'app.py')
-rw-r--r-- | app.py | 35 |
1 files changed, 22 insertions, 13 deletions
@@ -29,8 +29,7 @@ logging.basicConfig(level=logging.DEBUG) log = logging.getLogger() -@get("/") -async def get_index() -> Template: +def random_light() -> Template: hue = randint(0, 65535) saturation = randint(0, 65535) brightness = randint(0, 65535) @@ -68,19 +67,29 @@ async def get_index() -> Template: ) +@get("/") +async def get_index() -> Template: + return random_light() + + @post("/") -async def post_index( - hue: int, saturation: int, brightness: int, kelvin: int -) -> dict[str, str]: - try: - lifxlan.set_color_all_lights( - [hue, saturation, brightness, kelvin], - rapid=True, - ) - except Exception as e: - return {"status": "error", "message": str(e)} +async def post_index() -> Template: + return random_light() + + +# @post("/") +# async def post_index( +# hue: int, saturation: int, brightness: int, kelvin: int +# ) -> dict[str, str]: +# try: +# lifxlan.set_color_all_lights( +# [hue, saturation, brightness, kelvin], +# rapid=True, +# ) +# except Exception as e: +# return {"status": "error", "message": str(e)} - return {"status": "ok"} +# return {"status": "ok"} app = Litestar( |