From 4484edaf88d898690a2731c03a487a5c46d8b986 Mon Sep 17 00:00:00 2001 From: Michael McVady Date: Mon, 12 Feb 2024 12:59:42 -0600 Subject: GET and POST do the same for now --- app.py | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/app.py b/app.py index ab23e45..6187c0a 100644 --- a/app.py +++ b/app.py @@ -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( -- cgit v1.2.3