From 82aefaaaf1c0fc64e584f7025259f84d2bcc347b Mon Sep 17 00:00:00 2001 From: neodarz Date: Thu, 17 Jan 2019 22:20:46 +0100 Subject: Add index selection --- app.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'app.py') diff --git a/app.py b/app.py index 42e9055..933a140 100644 --- a/app.py +++ b/app.py @@ -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(): -- cgit v1.2.1