initial commit
commit
90b05a16db
|
|
@ -0,0 +1 @@
|
||||||
|
/venv
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
'''
|
||||||
|
A basic bottle app skeleton
|
||||||
|
'''
|
||||||
|
|
||||||
|
from bottle import Bottle, get, request, run
|
||||||
|
import paho.mqtt.client as mqtt
|
||||||
|
|
||||||
|
mqttc = mqtt.Client(client_id="", clean_session=True, userdata=None, transport="tcp")
|
||||||
|
|
||||||
|
mqttc.username_pw_set("th", password="h82b7782")
|
||||||
|
mqttc.connect("172.16.1.70", port=1883)
|
||||||
|
mqttc.loop_start()
|
||||||
|
|
||||||
|
app = Bottle()
|
||||||
|
|
||||||
|
@get('/unlock')
|
||||||
|
def unlock():
|
||||||
|
deviceID = request.query.get('deviceID')
|
||||||
|
apiKey = request.query.get('apiKey')
|
||||||
|
delay = request.query.get('delay')
|
||||||
|
|
||||||
|
if apiKey == "123":
|
||||||
|
result = mqttc.publish("devices/main-door/unlock/unlock/set", "true")
|
||||||
|
result.wait_for_publish()
|
||||||
|
return "<div>Unlocked!</div>"
|
||||||
|
#?deviceID=${dID}&apiKey=${aK}&delay=${d}
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
run(
|
||||||
|
host='localhost',
|
||||||
|
port=8000)
|
||||||
Loading…
Reference in New Issue