From c560de266caad6db97e58757ca43e8558c103c01 Mon Sep 17 00:00:00 2001 From: Anson Bridges Date: Sat, 18 Nov 2023 06:18:23 -0500 Subject: csv import, manual visiting --- dashboard_website/dashboard.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'dashboard_website/dashboard.py') diff --git a/dashboard_website/dashboard.py b/dashboard_website/dashboard.py index 06af267..7d0d920 100644 --- a/dashboard_website/dashboard.py +++ b/dashboard_website/dashboard.py @@ -215,6 +215,15 @@ def getLatestInfo(): return jsonify(data) +@app.route("/addClue", methods=['POST']) +def addClueWeb(): + content = request.get_json() + + if not ('clue_name' in content and 'longitude' in content and 'latitude' in content and 'clue_info' in content): + return jsonify({'status' : "ERROR 1"}) + + return jsonify({'status' : "OK",}) + # main page # GET = get main page @@ -223,6 +232,32 @@ def siteIndex(): #clues = db.getClues(); bikes = db.getBikes() return render_template("index.html")#, clues=clues, bikes=bikes) +# add csv, download as csv +@app.route("/controls", methods=['GET', 'POST']) +def siteControls(): + if request.method == "GET": + return render_template("controls.html") + if request.method == "POST": + cmd = request.form.get('command') + print(cmd) + if cmd == "downloadSave": + print("send") + db.save() + return send_from_directory(".", "savefile.csv", as_attachment=True) + elif cmd == "loadDirty": + dirty_csv = request.files['dirtyfile'] + dirty_csv.save("dirt.csv") + if db.loadDirty("dirt.csv") != 0: + return jsonify({"status" : "ERROR"}) + return jsonify({"status" : "OK"}) + elif cmd == "loadClean": + dirty_csv = request.files['cleanfile'] + dirty_csv.save("clean.csv") + if db.load("clean.csv") != 0: + return jsonify({"status" : "ERROR"}) + return jsonify({"status" : "OK"}) + + return render_template("controls.html") if __name__ == "__main__": -- cgit v1.2.3