viewer: add basic buttons to lock/unlock front door
This commit is contained in:
parent
1f5acb1a91
commit
48333d1e6d
@ -50,6 +50,13 @@ def sendCardFormat(targetIP, formatName, templateID, facilityCode):
|
||||
attrib={"value": str(facilityCode)})
|
||||
return doXMLRequest(targetIP, ET.tostring(el))
|
||||
|
||||
def lockOrUnlockDoor(targetIP, lock=True):
|
||||
el = ET.Element("VertXMessage")
|
||||
ET.SubElement(el, "hid:Doors",
|
||||
attrib={"action": "CM",
|
||||
"command": "lockDoor" if lock else "unlockDoor"})
|
||||
return doXMLRequest(targetIP, ET.tostring(el))
|
||||
|
||||
def forEachDoor(fxn):
|
||||
for doorName, doorData in config["doors"].items():
|
||||
print(doorName)
|
||||
|
@ -1,11 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
import re
|
||||
import http
|
||||
|
||||
from flask import Flask, render_template, request
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
from common import *
|
||||
from doorUtil import lockOrUnlockDoor
|
||||
|
||||
def parse_list(member, regex):
|
||||
data_list = []
|
||||
@ -60,5 +62,10 @@ def main():
|
||||
|
||||
return render_template("members.html", headers=headers, members=members)
|
||||
|
||||
@app.route('/frontDoor/<lock>', methods=['POST'])
|
||||
def unlockLockDoor(lock):
|
||||
lockOrUnlockDoor(config['doors']['Front Door']['ip'], lock != 'unlock')
|
||||
return ('', http.HTTPStatus.NO_CONTENT)
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(debug=True, host='0.0.0.0')
|
||||
|
@ -24,6 +24,10 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<form action="./frontDoor/lock" method="post">
|
||||
<button>Lock Front Door</button>
|
||||
<button formaction="./frontDoor/unlock">Unlock Front Door</button>
|
||||
</form>
|
||||
<form>
|
||||
<input type="text" name="term" />
|
||||
<button>Search</button>
|
||||
|
Reference in New Issue
Block a user