From 9df483045b5622af8902c07b54c7f985e12b1671 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Mon, 18 Jun 2018 16:00:16 +0200 Subject: Add DPD page to web gui --- gui/api/__init__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'gui/api') diff --git a/gui/api/__init__.py b/gui/api/__init__.py index 1bc95a6..959dedc 100755 --- a/gui/api/__init__.py +++ b/gui/api/__init__.py @@ -31,8 +31,9 @@ import io import datetime class API: - def __init__(self, mod_rc): + def __init__(self, mod_rc, dpd): self.mod_rc = mod_rc + self.dpd = dpd @cherrypy.expose def index(self): @@ -60,3 +61,13 @@ class API: cherrypy.response.headers["Content-Type"] = "application/json" cherrypy.response.status = 400 return json.dumps("POST only").encode() + + @cherrypy.expose + def trigger_capture(self, **kwargs): + if cherrypy.request.method == 'POST': + cherrypy.response.headers["Content-Type"] = "text/plain" + return self.dpd.capture_samples() + else: + cherrypy.response.headers["Content-Type"] = "text/plain" + cherrypy.response.status = 400 + return "POST only" -- cgit v1.2.3