commit 90b05a16db93ad9584869188bc60e22d3d7bb558 Author: Bryan Date: Sun Mar 14 10:50:43 2021 -0600 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f9606a3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/venv diff --git a/src/app.py b/src/app.py new file mode 100644 index 0000000..d987d45 --- /dev/null +++ b/src/app.py @@ -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 "
Unlocked!
" +#?deviceID=${dID}&apiKey=${aK}&delay=${d} + + +if __name__ == '__main__': + run( + host='localhost', + port=8000)