diff options
author | Alexandre Flament <alex@al-f.net> | 2021-09-18 10:59:56 +0200 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2021-09-24 20:20:30 +0200 |
commit | bfd24d1226ccdd1a9c7b07ff240a2198ab4d655b (patch) | |
tree | d27dc2dd80594a67dbff7accfff797c748afa481 /searx/webapp.py | |
parent | f8d5fe0f1133ad07c7170e1f5662390ad4299e79 (diff) | |
download | searxng-bfd24d1226ccdd1a9c7b07ff240a2198ab4d655b.tar.gz searxng-bfd24d1226ccdd1a9c7b07ff240a2198ab4d655b.zip |
[mod] add /engine_descriptions.json endpoint
returns engine descriptions (JSON):
* key: engine name
* value: description in the user locale, use English description as a fallback
Diffstat (limited to 'searx/webapp.py')
-rwxr-xr-x | searx/webapp.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/searx/webapp.py b/searx/webapp.py index cffde08a3..7209e3a57 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -54,6 +54,7 @@ from searx import ( settings, searx_debug, ) +from searx.data import ENGINE_DESCRIPTIONS from searx.settings_defaults import OUTPUT_FORMATS from searx.settings_loader import get_default_settings_path from searx.exceptions import SearxParameterException @@ -1140,6 +1141,23 @@ def image_proxy(): return '', 400 +@app.route('/engine_descriptions.json', methods=['GET']) +def engine_descriptions(): + locale = get_locale().split('_')[0] + result = ENGINE_DESCRIPTIONS['en'].copy() + if locale != 'en': + for engine, description in ENGINE_DESCRIPTIONS.get(locale, {}).items(): + result[engine] = description + for engine, description in result.items(): + if len(description) ==2 and description[1] == 'ref': + ref_engine, ref_lang = description[0].split(':') + description = ENGINE_DESCRIPTIONS[ref_lang][ref_engine] + if isinstance(description, str): + description = [ description, 'wikipedia' ] + result[engine] = description + return jsonify(result) + + @app.route('/stats', methods=['GET']) def stats(): """Render engine statistics page.""" |