diff options
author | Michael McVady <michaelm@telnyx.com> | 2024-02-12 12:59:42 -0600 |
---|---|---|
committer | Michael McVady <michaelm@telnyx.com> | 2024-02-12 12:59:42 -0600 |
commit | 4484edaf88d898690a2731c03a487a5c46d8b986 (patch) | |
tree | bce6a2a5733e939806837887db05467b1ed40fcd /app.py | |
parent | 62c313996536cb88a3ea09f4344cb2bdaa5cacca (diff) |
GET and POST do the same for now
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( |