Add /data/<key> to get value of certain key

This commit is contained in:
Ceda EI 2020-12-19 19:38:59 +05:30
parent 46fc7a7a63
commit 2ba463c9dc
1 changed files with 6 additions and 0 deletions

6
app.py
View File

@ -23,6 +23,12 @@ def set_data_point(data_id):
json.dump(data, f) json.dump(data, f)
return jsonify({"success": True}) return jsonify({"success": True})
@app.route("/data/<key>")
def get_data_point(key):
if key not in data:
return jsonify({"success": False}), 404
return jsonify({"success": True, "value": data[key]})
@app.route("/admin/") @app.route("/admin/")
def admin(): def admin():
return render_template("admin.html", data=data) return render_template("admin.html", data=data)