Changeset - 632c4f992443
[Not reviewed]
default
0 1 0
Dennis Fink - 10 years ago 2015-07-08 22:23:53

decode early
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
spaceapi/sensors.py
Show inline comments
 
@@ -65,27 +65,27 @@ def set_radiation_value(data):
 
        except ValueError:
 
            active_json['sensors']['radiaton'][first_subkey].append(data)
 

	
 
    save_last_state()
 
    return jsonify(active_json)
 

	
 

	
 
@sensors_views.route('/set/<key>', methods=['POST'])
 
@httpauth.login_required
 
def set_sensors(key):
 

	
 
    if key in ALLOWED_SENSORS_KEYS and key in active_json['sensors']:
 
        data = request.data
 
        data = request.data.decode('utf-8')
 
        try:
 
            data = json.loads(data.decode('utf-8'))
 
            data = json.loads(data)
 

	
 
            try:
 
                jsonschema.validate(data, ALLOWED_SENSORS_KEYS[key])
 
            except jsonschema.ValidationError:
 
                current_app.logger.info('Validation Error')
 
                return abort(400)
 

	
 
            if key != 'radiation':
 
                return set_value(data, key)
 
            else:
 
                return set_radiation_value(data)
 

	
0 comments (0 inline, 0 general)