@app.route('<STR_LIT>', methods=['<STR_LIT:GET>', '<STR_LIT:POST>'])<EOL>def preferences():
<EOL>if request.method == '<STR_LIT:POST>':<EOL><INDENT>resp = make_response(redirect(urljoin(settings['<STR_LIT>']['<STR_LIT>'], url_for('<STR_LIT:index>'))))<EOL>try:<EOL><INDENT>request.preferences.parse_form(request.form)<EOL><DEDENT>except ValidationException:<EOL><INDENT>request.errors.append(gettext('<STR_LIT>'))<EOL>return resp<EOL><DEDENT>return request.preferences.save(resp)<EOL><DEDENT>image_proxy = request.preferences.get_value('<STR_LIT>')<EOL>lang = request.preferences.get_value('<STR_LIT>')<EOL>disabled_engines = request.preferences.engines.get_disabled()<EOL>allowed_plugins = request.preferences.plugins.get_enabled()<EOL>stats = {}<EOL>for c in categories:<EOL><INDENT>for e in categories[c]:<EOL><INDENT>stats[e.name] = {'<STR_LIT:time>': None,<EOL>'<STR_LIT>': False,<EOL>'<STR_LIT>': False}<EOL>if e.timeout > settings['<STR_LIT>']['<STR_LIT>']:<EOL><INDENT>stats[e.name]['<STR_LIT>'] = True<EOL><DEDENT>stats[e.name]['<STR_LIT>'] = _is_selected_language_supported(e, request.preferences)<EOL><DEDENT><DEDENT>for engine_stat in get_engines_stats()[<NUM_LIT:0>][<NUM_LIT:1>]:<EOL><INDENT>stats[engine_stat.get('<STR_LIT:name>')]['<STR_LIT:time>'] = round(engine_stat.get('<STR_LIT>'), <NUM_LIT:3>)<EOL>if engine_stat.get('<STR_LIT>') > settings['<STR_LIT>']['<STR_LIT>']:<EOL><INDENT>stats[engine_stat.get('<STR_LIT:name>')]['<STR_LIT>'] = True<EOL><DEDENT><DEDENT>return render('<STR_LIT>',<EOL>locales=settings['<STR_LIT>'],<EOL>current_locale=get_locale(),<EOL>image_proxy=image_proxy,<EOL>engines_by_category=categories,<EOL>stats=stats,<EOL>answerers=[{'<STR_LIT:info>': a.self_info(), '<STR_LIT>': a.keywords} for a in answerers],<EOL>disabled_engines=disabled_engines,<EOL>autocomplete_backends=autocomplete_backends,<EOL>shortcuts={y: x for x, y in engine_shortcuts.items()},<EOL>themes=themes,<EOL>plugins=plugins,<EOL>doi_resolvers=settings['<STR_LIT>'],<EOL>current_doi_resolver=get_doi_resolver(request.args, request.preferences.get_value('<STR_LIT>')),<EOL>allowed_plugins=allowed_plugins,<EOL>theme=get_current_theme_name(),<EOL>preferences_url_params=request.preferences.get_as_url_params(),<EOL>base_url=get_base_url(),<EOL>preferences=True)<EOL>
Render preferences page && save user preferences