forked from nat/sludge
add bracelet control api
This commit is contained in:
parent
bce0d97e23
commit
80212a5c03
@ -11,6 +11,7 @@ from .patchers import patchers
|
||||
from .logger import log
|
||||
import os
|
||||
import traceback
|
||||
import requests, json
|
||||
|
||||
@dataclass
|
||||
class Route:
|
||||
@ -47,6 +48,31 @@ routes = [
|
||||
parse_file('./index.html').encode('utf-8')
|
||||
)
|
||||
),
|
||||
Route(
|
||||
lambda request: request.path == '/bracelet.html',
|
||||
[Method.POST],
|
||||
lambda request, *_: Response(
|
||||
ResponseCode.OK,
|
||||
{'Content-Type': 'text/html'},
|
||||
(
|
||||
requests.post(
|
||||
"https://api.pavlok.com/api/v5/stimulus/send",
|
||||
headers = { # who cares about a pavlok api key
|
||||
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6bnVsbCwiaWQiOjMxNDA3NiwiZW1haWwiOiJvZGV0dGVhbWF0bzA3QGdtYWlsLmNvbSIsImlzX2FwcGxpY2F0aW9uIjpmYWxzZSwiZXhwIjoxNzYxMzcyMzIwLCJzdWIiOiJhY2Nlc3MifQ.8dyKDR6opM8dpzXfnXpIO1VJApx880mN6fCrmVUShxc',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
data = json.dumps({
|
||||
"stimulus": {
|
||||
"stimulusType": request.body.data['type'],
|
||||
"stimulusValue": request.body.data['strength'],
|
||||
"reason": request.body.data['message'],
|
||||
}
|
||||
})
|
||||
),
|
||||
parse_file('./bracelet.html').encode('utf-8')
|
||||
)[-1]
|
||||
)
|
||||
),
|
||||
Route(
|
||||
lambda request: os.path.isfile('.' + request.path) and request.path.endswith('.html'),
|
||||
[Method.GET],
|
||||
|
Loading…
x
Reference in New Issue
Block a user