aboutsummaryrefslogtreecommitdiff
path: root/app.py
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2019-01-17 22:20:46 +0100
committerneodarz <neodarz@neodarz.net>2019-01-17 22:20:46 +0100
commit82aefaaaf1c0fc64e584f7025259f84d2bcc347b (patch)
tree00a7094105d23cca35525bee0f1f80a8e5faff1d /app.py
parent5fe782772472914ce454198e5a6f3b40e2ecdb69 (diff)
downloadkhanindexer-82aefaaaf1c0fc64e584f7025259f84d2bcc347b.tar.xz
khanindexer-82aefaaaf1c0fc64e584f7025259f84d2bcc347b.zip
Add index selection
Diffstat (limited to 'app.py')
-rw-r--r--app.py12
1 files changed, 9 insertions, 3 deletions
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():