mirror of
https://github.com/searxng/searxng.git
synced 2024-11-22 20:17:45 +01:00
webapp.py: partial code review (no functional change)
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
d471ec86dd
commit
ace7d30aed
@ -958,24 +958,37 @@ def clear_cookies():
|
|||||||
|
|
||||||
@app.route('/config')
|
@app.route('/config')
|
||||||
def config():
|
def config():
|
||||||
return jsonify({'categories': list(categories.keys()),
|
"""Return configuration in JSON format."""
|
||||||
'engines': [{'name': name,
|
_engines = []
|
||||||
|
for name, engine in engines.items():
|
||||||
|
if not request.preferences.validate_token(engine):
|
||||||
|
continue
|
||||||
|
|
||||||
|
supported_languages = engine.supported_languages
|
||||||
|
if isinstance(engine.supported_languages, dict):
|
||||||
|
supported_languages = list(engine.supported_languages.keys())
|
||||||
|
|
||||||
|
_engines.append({
|
||||||
|
'name': name,
|
||||||
'categories': engine.categories,
|
'categories': engine.categories,
|
||||||
'shortcut': engine.shortcut,
|
'shortcut': engine.shortcut,
|
||||||
'enabled': not engine.disabled,
|
'enabled': not engine.disabled,
|
||||||
'paging': engine.paging,
|
'paging': engine.paging,
|
||||||
'language_support': engine.language_support,
|
'language_support': engine.language_support,
|
||||||
'supported_languages':
|
'supported_languages': supported_languages,
|
||||||
list(engine.supported_languages.keys())
|
|
||||||
if isinstance(engine.supported_languages, dict)
|
|
||||||
else engine.supported_languages,
|
|
||||||
'safesearch': engine.safesearch,
|
'safesearch': engine.safesearch,
|
||||||
'time_range_support': engine.time_range_support,
|
'time_range_support': engine.time_range_support,
|
||||||
'timeout': engine.timeout}
|
'timeout': engine.timeout
|
||||||
for name, engine in engines.items() if request.preferences.validate_token(engine)],
|
})
|
||||||
'plugins': [{'name': plugin.name,
|
|
||||||
'enabled': plugin.default_on}
|
_plugins = []
|
||||||
for plugin in plugins],
|
for _ in plugins:
|
||||||
|
_plugins.append({'name': _.name, 'enabled': _.default_on})
|
||||||
|
|
||||||
|
return jsonify({
|
||||||
|
'categories': list(categories.keys()),
|
||||||
|
'engines': _engines,
|
||||||
|
'plugins': _plugins,
|
||||||
'instance_name': settings['general']['instance_name'],
|
'instance_name': settings['general']['instance_name'],
|
||||||
'locales': settings['locales'],
|
'locales': settings['locales'],
|
||||||
'default_locale': settings['ui']['default_locale'],
|
'default_locale': settings['ui']['default_locale'],
|
||||||
|
Loading…
Reference in New Issue
Block a user