initial commit

master
Bryan 2021-03-14 10:50:43 -06:00
commit 90b05a16db
2 changed files with 34 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/venv

33
src/app.py Normal file
View File

@ -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)