diff options
author | neodarz <neodarz@neodarz.net> | 2019-01-17 22:20:46 +0100 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2019-01-17 22:20:46 +0100 |
commit | 82aefaaaf1c0fc64e584f7025259f84d2bcc347b (patch) | |
tree | 00a7094105d23cca35525bee0f1f80a8e5faff1d /app.py | |
parent | 5fe782772472914ce454198e5a6f3b40e2ecdb69 (diff) | |
download | khanindexer-82aefaaaf1c0fc64e584f7025259f84d2bcc347b.tar.xz khanindexer-82aefaaaf1c0fc64e584f7025259f84d2bcc347b.zip |
Add index selection
Diffstat (limited to 'app.py')
-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(): |