forked from zaclys/searxng
[enh] engine selection support
This commit is contained in:
parent
e4b768b6cc
commit
9e1ded688f
@ -28,12 +28,14 @@ def make_callback(engine_name, results, callback):
|
||||
results.append(result)
|
||||
return process_callback
|
||||
|
||||
def search(query, request):
|
||||
def search(query, request, selected_engines):
|
||||
global engines
|
||||
requests = []
|
||||
results = []
|
||||
user_agent = request.headers.get('User-Agent', '')
|
||||
for ename, engine in engines.items():
|
||||
if ename not in selected_engines:
|
||||
continue
|
||||
headers = default_request_params()
|
||||
headers['User-Agent'] = user_agent
|
||||
request_params = engine.request(query, headers)
|
||||
|
@ -47,8 +47,14 @@ def index():
|
||||
if not request.form.get('q'):
|
||||
flash('Wrong post data')
|
||||
return render('index.html')
|
||||
selected_engines = []
|
||||
for pd_name,pd in request.form.items():
|
||||
print pd
|
||||
if pd_name.startswith('engine_'):
|
||||
selected_engines.append(pd_name[7:])
|
||||
print selected_engines
|
||||
query = request.form['q']
|
||||
results = search(query, request)
|
||||
results = search(query, request, selected_engines)
|
||||
return render('results.html', results=results, q=query)
|
||||
return render('index.html')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user