Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions app/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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"
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"dependencies": {
"bower": "^1.8.0"
},
"scripts":
{
"postinstall": "bower install"
}
"scripts": {
"postinstall": "bower install"
}
}