diff options
Diffstat (limited to 'searx/engines/demo_offline.py')
| -rw-r--r-- | searx/engines/demo_offline.py | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/searx/engines/demo_offline.py b/searx/engines/demo_offline.py index ffcdb46a9..2cef4f0d0 100644 --- a/searx/engines/demo_offline.py +++ b/searx/engines/demo_offline.py @@ -13,6 +13,7 @@ close to the implementation, its just a simple example. To get in use of this """ import json + from searx.result_types import EngineResults engine_type = 'offline' @@ -29,7 +30,7 @@ about = { } # if there is a need for globals, use a leading underline -_my_offline_engine = None +_my_offline_engine: str = "" def init(engine_settings=None): @@ -50,24 +51,28 @@ def init(engine_settings=None): def search(query, request_params) -> EngineResults: - """Query (offline) engine and return results. Assemble the list of results from - your local engine. In this demo engine we ignore the 'query' term, usual - you would pass the 'query' term to your local engine to filter out the + """Query (offline) engine and return results. Assemble the list of results + from your local engine. In this demo engine we ignore the 'query' term, + usual you would pass the 'query' term to your local engine to filter out the results. - """ res = EngineResults() - result_list = json.loads(_my_offline_engine) - - for row in result_list: - entry = { + count = 0 + for row in json.loads(_my_offline_engine): + count += 1 + kvmap = { 'query': query, 'language': request_params['searxng_locale'], 'value': row.get("value"), - # choose a result template or comment out to use the *default* - 'template': 'key-value.html', } - res.append(entry) - + res.add( + res.types.KeyValue( + caption=f"Demo Offline Engine Result #{count}", + key_title="Name", + value_title="Value", + kvmap=kvmap, + ) + ) + res.add(res.types.LegacyResult(number_of_results=count)) return res |