From 6bddaf57022dea1783cd08c4d18e6744d1048bea Mon Sep 17 00:00:00 2001 From: asciimoo Date: Wed, 16 Oct 2013 00:01:08 +0200 Subject: [PATCH] [enh] opensearch xml added --- searx/templates/base.html | 1 + searx/webapp.py | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/searx/templates/base.html b/searx/templates/base.html index b1b051fad..58a278a29 100644 --- a/searx/templates/base.html +++ b/searx/templates/base.html @@ -5,6 +5,7 @@ + searx {% block title %}{% endblock %} {% block styles %} diff --git a/searx/webapp.py b/searx/webapp.py index 38084714a..afd7d19ca 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -22,7 +22,7 @@ if __name__ == "__main__": from os.path import realpath, dirname path.append(realpath(dirname(realpath(__file__))+'/../')) -from flask import Flask, request, flash, render_template +from flask import Flask, request, flash, render_template, url_for, Response import ConfigParser from os import getenv from searx.engines import search, engines @@ -37,6 +37,18 @@ cfg.read('searx.conf') app = Flask(__name__) app.secret_key = cfg.get('app', 'secret_key') +opensearch_xml = ''' + + searx + Search searx + UTF-8 + searx meta search engine + + + + +''' + def render(template_name, **kwargs): kwargs['engines'] = engines.keys() return render_template(template_name, **kwargs) @@ -58,6 +70,19 @@ def index(): return render('results.html', results=results, q=query.decode('utf-8')) return render('index.html') +@app.route('/favicon.ico', methods=['GET']) +def fav(): + return '' + +@app.route('/opensearch.xml', methods=['GET']) +def opensearch(): + global opensearch_xml + ret = opensearch_xml.format(host=url_for('index', _external=True)) + resp = Response(response=ret, + status=200, + mimetype="application/xml") + return resp + if __name__ == "__main__": from gevent import monkey monkey.patch_all()