mirror of https://github.com/searxng/searxng.git
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,34 +958,47 @@ 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 = []
|
||||||
'categories': engine.categories,
|
for name, engine in engines.items():
|
||||||
'shortcut': engine.shortcut,
|
if not request.preferences.validate_token(engine):
|
||||||
'enabled': not engine.disabled,
|
continue
|
||||||
'paging': engine.paging,
|
|
||||||
'language_support': engine.language_support,
|
supported_languages = engine.supported_languages
|
||||||
'supported_languages':
|
if isinstance(engine.supported_languages, dict):
|
||||||
list(engine.supported_languages.keys())
|
supported_languages = list(engine.supported_languages.keys())
|
||||||
if isinstance(engine.supported_languages, dict)
|
|
||||||
else engine.supported_languages,
|
_engines.append({
|
||||||
'safesearch': engine.safesearch,
|
'name': name,
|
||||||
'time_range_support': engine.time_range_support,
|
'categories': engine.categories,
|
||||||
'timeout': engine.timeout}
|
'shortcut': engine.shortcut,
|
||||||
for name, engine in engines.items() if request.preferences.validate_token(engine)],
|
'enabled': not engine.disabled,
|
||||||
'plugins': [{'name': plugin.name,
|
'paging': engine.paging,
|
||||||
'enabled': plugin.default_on}
|
'language_support': engine.language_support,
|
||||||
for plugin in plugins],
|
'supported_languages': supported_languages,
|
||||||
'instance_name': settings['general']['instance_name'],
|
'safesearch': engine.safesearch,
|
||||||
'locales': settings['locales'],
|
'time_range_support': engine.time_range_support,
|
||||||
'default_locale': settings['ui']['default_locale'],
|
'timeout': engine.timeout
|
||||||
'autocomplete': settings['search']['autocomplete'],
|
})
|
||||||
'safe_search': settings['search']['safe_search'],
|
|
||||||
'default_theme': settings['ui']['default_theme'],
|
_plugins = []
|
||||||
'version': VERSION_STRING,
|
for _ in plugins:
|
||||||
'doi_resolvers': [r for r in settings['doi_resolvers']],
|
_plugins.append({'name': _.name, 'enabled': _.default_on})
|
||||||
'default_doi_resolver': settings['default_doi_resolver'],
|
|
||||||
})
|
return jsonify({
|
||||||
|
'categories': list(categories.keys()),
|
||||||
|
'engines': _engines,
|
||||||
|
'plugins': _plugins,
|
||||||
|
'instance_name': settings['general']['instance_name'],
|
||||||
|
'locales': settings['locales'],
|
||||||
|
'default_locale': settings['ui']['default_locale'],
|
||||||
|
'autocomplete': settings['search']['autocomplete'],
|
||||||
|
'safe_search': settings['search']['safe_search'],
|
||||||
|
'default_theme': settings['ui']['default_theme'],
|
||||||
|
'version': VERSION_STRING,
|
||||||
|
'doi_resolvers': [r for r in settings['doi_resolvers']],
|
||||||
|
'default_doi_resolver': settings['default_doi_resolver'],
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
@app.errorhandler(404)
|
@app.errorhandler(404)
|
||||||
|
|
Loading…
Reference in New Issue