forked from gaussmeter/teslamater
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
40 lines (39 loc) · 1.09 KB
/
Copy pathconfig.py
File metadata and controls
40 lines (39 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from flask import Flask, request, abort
import app
@app.route('/lumen', methods=['POST'])
def lumen():
if not request.json:
return 'Bad request', 400
lumen = request.json.get('lumen')
if not lumen:
return 'Bad request', 400
bright = lumen.get('bright', 255)
animation = lumen.get('animation', 'cylon')
percent = lumen.get('percent', 10)
velocity = lumen.get('velocity', 30)
r = lumen.get('r', 0)
g = lumen.get('g', 0)
b = lumen.get('b', 0)
w = lumen.get('w', 255)
r2 = lumen.get('r2', 0)
g2 = lumen.get('g2', 0)
b2 = lumen.get('b2', 0)
w2 = lumen.get('w2', 255)
return 'OK', ('200', 0)
g = lumen.get('g', 0)
b = lumen.get('b', 0)
w = lumen.get('w', 255)
r2 = lumen.get('r2', 0)
g2 = lumen.get('g2', 0)
b2 = lumen.get('b2', 0)
w2 = lumen.get('w2', 255)
if not (0 <= bright <= 255):
abort(400)
if not (0 <= percent <= 100):
abort(400)
if not (0 <= velocity <= 100):
abort(400)
if not (0 <= r <= 255):
abort(400)
if not (0 <= g <= 255):
abort(400)