diff options
Diffstat (limited to '')
-rw-r--r-- | app.py | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -17,12 +17,18 @@ app = Flask(__name__) @app.route("/", methods=['GET', 'POST']) def search(): query = request.args.get('search') - if query != '' and query != None: - response = sphinx.search(query) + index = request.args.get('index') + if query != '' and query != None and index != '' and index != None: + response = sphinx.search(query, index) elif query is None: response = {'error': 1, 'msg': 'Use `search` attribute for make a search'} + elif index == None: + response = {'error': 1, 'msg': 'Use `index` attribute to precise an index'} + elif index == '': + + response = {'error': 1, 'msg': '`index` cannot be null'} else: - response = {'error': 1, 'msg': 'Query cannot be null'} + response = {'error': 1, 'msg': '`search` cannot be null'} return jsonify(response) def crawl(): |