From 69c300dd4b84874944f58b7a5f764fc5af896dba Mon Sep 17 00:00:00 2001 From: Michael McVady Date: Sun, 28 Jan 2024 22:21:16 -0600 Subject: Bikeshedding --- app.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'app.py') diff --git a/app.py b/app.py index 9fb5971..27f7a9e 100644 --- a/app.py +++ b/app.py @@ -9,11 +9,18 @@ from litestar.contrib.jinja import JinjaTemplateEngine from litestar.response import Template from litestar.template import TemplateConfig +# FIXME: discovery happens here, but things can change. +# Try power cycling the light and see what happens. lifxlan = LifxLAN() DEFAULT_COLOR = "#FF0000" -TEMPLATE_STR = '

{{ message }}

' - +TEMPLATE_STR = """ + + +

{{ message }}

+ + +""" logging.basicConfig(level=logging.DEBUG) log = logging.getLogger() @@ -40,12 +47,12 @@ async def get_index() -> Template: context={"color": DEFAULT_COLOR, "message": f"error: {str(e)}"}, ) - rgb_color = DEFAULT_COLOR + rgb_hex = DEFAULT_COLOR try: r, g, b = hsv_to_rgb(hue / 65535, saturation / 65535, brightness / 65535) log.info("RGB: %s, %s, %s", r, g, b) - rgb_color = "#%02x%02x%02x" % (int(r * 255), int(g * 255), int(b * 255)) - log.info("hex RGB: %s", rgb_color) + rgb_hex = "#%02x%02x%02x" % (int(r * 255), int(g * 255), int(b * 255)) + log.info("hex RGB: %s", rgb_hex) except Exception as e: log.exception("Error converting color") return Template( @@ -54,7 +61,7 @@ async def get_index() -> Template: ) return Template( - template_str=TEMPLATE_STR, context={"color": rgb_color, "message": ""} + template_str=TEMPLATE_STR, context={"color": rgb_hex, "message": ""} ) -- cgit v1.2.3