diff --git a/README.md b/README.md index 6ff218d5..19f153c0 100644 --- a/README.md +++ b/README.md @@ -29,11 +29,12 @@ The API(s) provided by query-server are as follows: > *format* : [ `json`, `xml` ] -A sample query : `/api/v1/search/bing?query=fossasia&format=xml` +A sample query : `/api/v1/search/bing?query=fossasia&format=xml&num=10` ## Error Codes 404 Not Found : Incorrect Search Engine, Zero Response 400 Bad Request : query and/or format is not in the correct format + 500 Internal Server Error : Server Error from Search Engine ## Dependencies diff --git a/app/server.py b/app/server.py index d44fc5d3..93b4f579 100644 --- a/app/server.py +++ b/app/server.py @@ -10,6 +10,11 @@ client = MongoClient(os.environ.get('MONGO_URI', 'mongodb://localhost:27017/')) db = client['query-server-v2'] +errorObj = { + 'type' : 'Internal Server Error', + 'status_code' : 500, + 'error' : 'Could not parse the page due to Internal Server Error' +} @app.route('/') def index(): @@ -67,8 +72,7 @@ def search(search_engine): return Response(xmlfeed, mimetype='application/xml') except Exception as e: - return (e) - + return Response(json.dumps(errorObj).encode('utf-8'),mimetype='application/json') @app.after_request def set_header(r): r.headers["Cache-Control"] = "no-cache" diff --git a/package.json b/package.json index 94edc743..a626bd07 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,7 @@ "dependencies": { "bower": "^1.8.0" }, - "scripts": - { - "postinstall": "bower install" - } + "scripts": { + "postinstall": "bower install" + } }