diff options
author | Michael McVady <michaelm@telnyx.com> | 2024-01-28 22:21:16 -0600 |
---|---|---|
committer | Michael McVady <michaelm@telnyx.com> | 2024-01-28 22:21:16 -0600 |
commit | 69c300dd4b84874944f58b7a5f764fc5af896dba (patch) | |
tree | 87205b15fb8c7627b4d2a85893419d1478b0606f /app.py | |
parent | 4e54b3e3160226f5b0d9a82aab2d3c7a3f151cdd (diff) |
Bikeshedding
Diffstat (limited to 'app.py')
-rw-r--r-- | app.py | 19 |
1 files changed, 13 insertions, 6 deletions
@@ -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 = '<!DOCTYPE html><html><body style="background-color: {{ color }}"><h1>{{ message }}</h1></body></html>' - +TEMPLATE_STR = """<!DOCTYPE html> +<html> +<body style="background-color: {{ color }}"> +<h1>{{ message }}</h1> +</body> +</html> +""" 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": ""} ) |