aboutsummaryrefslogtreecommitdiff
path: root/app.py
blob: d669836fa21d9a2b1709f8ecf67615bdfda054f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from lifxlan import LifxLAN, BLUE

from litestar import Litestar, get, post


@get("/")
async def index() -> str:
    return "Hello, world!"


@post("/")
async def post_index() -> dict[str, str]:
    lifxlan = LifxLAN()
    try:
        lifxlan.set_color_all_lights(BLUE, rapid=True)
    except Exception as e:
        return {"status": "error", "message": str(e)}

    return {"status": "ok"}


app = Litestar([index, post_index])