signal.signal(signal.SIGINT, handler)
def sense_armed():
+ global lastsense
try:
with gpiod.request_lines(
"/dev/gpiochip0",
else:
return "Method not allowed", 405
+ # end point for concluding a test
+ @cherrypy.expose
+ def endtest(self):
+ if cherrypy.request.method == 'GET':
+ status = "idle"
+ cherrypy.log("status " + status)
+ return "Test concluded"
+ else:
+ return "Method not allowed", 405
+
# end point for handling AJAX requests for current status
@cherrypy.expose
@cherrypy.tools.json_out()
const response = fetch("/armsystem", fetchOptions);
}
+ let status = "idle";
+
// start current test by just hitting an endpoint
function startTest() {
const fetchOptions = {
method: "GET",
};
- const response = fetch("/starttest", fetchOptions);
+ if (status == "idle") {
+ status = "testing";
+ document.querySelector('#startTest').textContent = 'End Test';
+ const response = fetch("/starttest", fetchOptions);
+ } else {
+ status = "idle";
+ document.querySelector('#startTest').textContent = 'Start Test';
+ const response = fetch("/endtest", fetchOptions);
+ }
}
</script>
</head>