diff --git a/README.md b/README.md index 83a5a11..93f0fff 100644 --- a/README.md +++ b/README.md @@ -37,3 +37,18 @@ Go enjoy the dashboard @ *localhost:5000* ## The client This is an example client and will also be used as first link in the machine. + +### Requirements + +A local http file server of some kind. + for ex the python http server. + +### Running + +Go into the correct directory with the code + + cd watcher + +with python's http server + + python -m http.server diff --git a/client/index.css b/client/index.css new file mode 100644 index 0000000..5e714e8 --- /dev/null +++ b/client/index.css @@ -0,0 +1,11 @@ +.input-group { + padding: 10px; +} + +input { + padding: 5px; +} + +label { + margin-right: 10px; +} diff --git a/client/index.html b/client/index.html new file mode 100644 index 0000000..f67053f --- /dev/null +++ b/client/index.html @@ -0,0 +1,33 @@ + + + + + + + + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+
+ +

Result:

+ + + + diff --git a/client/index.js b/client/index.js new file mode 100644 index 0000000..52f5972 --- /dev/null +++ b/client/index.js @@ -0,0 +1,20 @@ +let call_backend = function(e) { + type = event.target.getAttribute('name'); + + var url_base = document.forms["link"]["url-field"].value; + var run = document.forms["link"]["run-field"].value; + var link = document.forms["link"]["link-field"].value; + + x = new XMLHttpRequest(); + x.onreadystatechange = function() { + if (x.readyState === 4) { + console.log("response: " + x.responseText); + document.getElementById("result").innerHTML = x.responseText; + }; + }; + + var url = "http://" + url_base + "/link/" + (type === "start" ? "start" : "handoff") + "/" + run + "/" + link; + // console.log(url); + x.open("GET", url, true); + x.send(); +}; diff --git a/watcher/app.py b/watcher/app.py index 59a444a..6ce918e 100644 --- a/watcher/app.py +++ b/watcher/app.py @@ -9,9 +9,11 @@ import matplotlib.pyplot as plt import socketio from apscheduler.schedulers.background import BackgroundScheduler from flask import Flask, render_template, request +from flask_cors import CORS sio = socketio.Server() app = Flask(__name__) +cors = CORS(app) app.wsgi_app = socketio.WSGIApp(sio, app.wsgi_app) # We request users to send the run number to prevent accidentially getting old requests from a previous run diff --git a/watcher/requirements.txt b/watcher/requirements.txt index fb7f3f8..5fe90f2 100644 --- a/watcher/requirements.txt +++ b/watcher/requirements.txt @@ -1,4 +1,5 @@ flask +flask-cors python-socketio apscheduler matplotlib