Commit 85c6f9c1 authored by Nelso Jost's avatar Nelso Jost

NEW: added api route for getting board hash

parent 05693459
......@@ -14,6 +14,32 @@ from datetime import datetime
def JSONError(message):
return jsonify({'Error': message})
@api.route('/get/boardhash', methods=['POST'])
def get_boardhash():
if not request.json:
return JSONError("Request does not have a valid JSON attribute.")
js = request.json
if type(js) is str:
js = json.loads(js)
try:
board = Board.get(int(js['board_id']))
except:
return JSONError("Missing or invalid 'board_id' attribute.")
try:
user_checked = board.user.verify_password(js['user_password'])
except:
return JSONError("Missing or invalid 'user_password' attribute.")
if user_checked:
return jsonify({'board_hash': board._userhash})
else:
return JSONError("Invalid 'user_password'.")
@api.route('/post/rawsensordata', methods=['POST'])
def post_rawsensordata():
''' Expects a request with valid JSON attribute containing sensor data.
......
......@@ -73,7 +73,7 @@ http://dygraphs.com/tutorial.html
document.getElementById(
"{{ the_sensor.name + '_graphdiv' }}"),
{{ board.get_dygraph_data(the_sensor.name)|safe }},
{labelsUTC: true,
{labelsUTC: false,
labels: ["Data", "{{ the_sensor.unitymeasurement.measurement.name }}"]
});
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment