import gpiod
from gpiod.line import Direction, Value
import iio
+import json
import signal
import sys
import time
+# where we'll store all our test data
+DATAPATH = "/var/lib/quantimotor/"
+
n = 0
pressure = 0
thrust = 0
'server.socket_host' : '0.0.0.0',
'server.socket_port' : 80,
'server.thread_pool' : 8,
+ 'log.access_file': '/var/log/access.log',
+ 'log.error_file': '/var/log/error.log',
},
'/': {
'tools.staticdir.on': True,
class App:
+ # main user interface home page
@cherrypy.expose
def index(self):
return serve_file(os.path.join(path, 'index.html'))
+ # end point for accepting and saving test metadata
+ @cherrypy.expose
+ @cherrypy.tools.json_in()
+ def metadata(self):
+ if cherrypy.request.method == 'PUT':
+ jsondata = cherrypy.request.json
+ metadata_path = DATAPATH + "metadata.json"
+ with open(metadata_path, 'w') as json_file:
+ json.dump(jsondata, json_file, indent=2)
+ return "Data received and processed"
+ else:
+ return "Method not allowed", 405
+
+ # end point for handling AJAX requests for current status
@cherrypy.expose
@cherrypy.tools.json_out()
-
def getData(self):
global n
global pressure