aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael McVady <michaelm@telnyx.com>2024-02-12 12:59:42 -0600
committerMichael McVady <michaelm@telnyx.com>2024-02-12 12:59:42 -0600
commit4484edaf88d898690a2731c03a487a5c46d8b986 (patch)
treebce6a2a5733e939806837887db05467b1ed40fcd
parent62c313996536cb88a3ea09f4344cb2bdaa5cacca (diff)
GET and POST do the same for now
-rw-r--r--app.py35
1 files 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(