From 66848e0bf5955c19331c54d0571ff7d71628c7de Mon Sep 17 00:00:00 2001 From: Maxime Bloch Date: Fri, 20 Sep 2019 17:00:44 +0200 Subject: [PATCH] add client ideas, add checks for data override --- client_ideas.md | 8 ++++++++ watcher/app.py | 16 ++++++++++++---- watcher/static/index.js | 3 +++ 3 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 client_ideas.md create mode 100644 watcher/static/index.js diff --git a/client_ideas.md b/client_ideas.md new file mode 100644 index 0000000..5cb24c1 --- /dev/null +++ b/client_ideas.md @@ -0,0 +1,8 @@ +- morse sound + microfoon +- qr code -> 1 camera en een scherm +- file upload via tfp + file watcher +- ?? excel file ?? +- simple http request or netcat +- licht sensor +- andere sensors (vochtigheid, ...) + diff --git a/watcher/app.py b/watcher/app.py index adbd84e..b4427de 100644 --- a/watcher/app.py +++ b/watcher/app.py @@ -35,8 +35,12 @@ def link_start(run, index): if db["current_run"] != run: return "Wrong run number, you are probably behind.", 404 else: - db["run_data"][run]["data"][index]["start"] = datetime.datetime.now() - return "Success." + link_data = db["run_data"][run]["data"][index] + if link_data["start"]: + return "you already started in this run. Ignoring this request." + else: + link_data["start"] = datetime.datetime.now() + return "Success." @app.route("/link/handoff//") @@ -44,8 +48,12 @@ def link_handoff(run, index): if db["current_run"] != run: return "Wrong run number, you are probably behind.", 404 else: - db["run_data"][run]["data"][index]["handoff"] = datetime.datetime.now() - return "Success." + link_data = db["run_data"][run]["data"][index] + if link_data["handoff"]: + return "you already handed off control during this run. Ignoring this request" + else: + link_data["handoff"] = datetime.datetime.now() + return "Success." if __name__ == '__main__': diff --git a/watcher/static/index.js b/watcher/static/index.js new file mode 100644 index 0000000..1999b8b --- /dev/null +++ b/watcher/static/index.js @@ -0,0 +1,3 @@ +const io = require('socket.io-client'); +// or with import syntax +import io from 'socket.io-client';