Changeset - 3ec5be85acb4
[Not reviewed]
version_5
0 1 0
Dennis Fink - 10 years ago 2015-08-30 15:23:39
dennis.fink@c3l.lu
Use try except block for checking if we got json
1 file changed with 5 insertions and 3 deletions:
0 comments (0 inline, 0 general)
ennstatus/api/views.py
Show inline comments
 
@@ -5,6 +5,8 @@ from datetime import datetime
 
from flask import (Blueprint, request, current_app, jsonify, render_template,
 
                   abort)
 

	
 
from werkzeug.exceptions import BadRequest
 

	
 
import strict_rfc3339
 
import pygeoip
 

	
 
@@ -44,9 +46,9 @@ def update():
 
        current_app.logger.error(str(e))
 
        return abort(500)
 

	
 
    data = request.get_json()
 

	
 
    if data is None:
 
    try:
 
        data = request.get_json()
 
    except BadRequest:
 
        current_app.logger.info('No JSON data supplied!')
 
        return 'No JSON data supplied!\n', 400, {'Content-Type': 'text/plain'}
 

	
0 comments (0 inline, 0 general)