mirror of https://github.com/searxng/searxng.git
[enh] opensearch xml added
This commit is contained in:
parent
a346327c6f
commit
6bddaf5702
|
@ -5,6 +5,7 @@
|
||||||
<meta http-equiv="content-language" content="en" />
|
<meta http-equiv="content-language" content="en" />
|
||||||
<meta name="description" content="" />
|
<meta name="description" content="" />
|
||||||
<meta name="keywords" content="" />
|
<meta name="keywords" content="" />
|
||||||
|
<link title="searx" type="application/opensearchdescription+xml" rel="search" href="/opensearch.xml"/>
|
||||||
<title>searx {% block title %}{% endblock %}</title>
|
<title>searx {% block title %}{% endblock %}</title>
|
||||||
<link rel="stylesheet" href="/static/css/style.css" type="text/css" media="screen" charset="utf-8" />
|
<link rel="stylesheet" href="/static/css/style.css" type="text/css" media="screen" charset="utf-8" />
|
||||||
{% block styles %}
|
{% block styles %}
|
||||||
|
|
|
@ -22,7 +22,7 @@ if __name__ == "__main__":
|
||||||
from os.path import realpath, dirname
|
from os.path import realpath, dirname
|
||||||
path.append(realpath(dirname(realpath(__file__))+'/../'))
|
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
|
import ConfigParser
|
||||||
from os import getenv
|
from os import getenv
|
||||||
from searx.engines import search, engines
|
from searx.engines import search, engines
|
||||||
|
@ -37,6 +37,18 @@ cfg.read('searx.conf')
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.secret_key = cfg.get('app', 'secret_key')
|
app.secret_key = cfg.get('app', 'secret_key')
|
||||||
|
|
||||||
|
opensearch_xml = '''<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
|
||||||
|
<ShortName>searx</ShortName>
|
||||||
|
<Description>Search searx</Description>
|
||||||
|
<InputEncoding>UTF-8</InputEncoding>
|
||||||
|
<LongName>searx meta search engine</LongName>
|
||||||
|
<Url type="text/html" method="post" template="{host}">
|
||||||
|
<Param name="q" value="{{searchTerms}}" />
|
||||||
|
</Url>
|
||||||
|
</OpenSearchDescription>
|
||||||
|
'''
|
||||||
|
|
||||||
def render(template_name, **kwargs):
|
def render(template_name, **kwargs):
|
||||||
kwargs['engines'] = engines.keys()
|
kwargs['engines'] = engines.keys()
|
||||||
return render_template(template_name, **kwargs)
|
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('results.html', results=results, q=query.decode('utf-8'))
|
||||||
return render('index.html')
|
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__":
|
if __name__ == "__main__":
|
||||||
from gevent import monkey
|
from gevent import monkey
|
||||||
monkey.patch_all()
|
monkey.patch_all()
|
||||||
|
|
Loading…
Reference in New Issue