|  | @@ -22,7 +22,7 @@ if __name__ == "__main__":
 | 
	
		
			
			| 22 | 22 |      from os.path import realpath, dirname
 | 
	
		
			
			| 23 | 23 |      path.append(realpath(dirname(realpath(__file__))+'/../'))
 | 
	
		
			
			| 24 | 24 |  
 | 
	
		
			
			| 25 |  | -from flask import Flask, request, flash, render_template
 | 
	
		
			
			|  | 25 | +from flask import Flask, request, flash, render_template, url_for, Response
 | 
	
		
			
			| 26 | 26 |  import ConfigParser
 | 
	
		
			
			| 27 | 27 |  from os import getenv
 | 
	
		
			
			| 28 | 28 |  from searx.engines import search, engines
 | 
	
	
		
			
			|  | @@ -37,6 +37,18 @@ cfg.read('searx.conf')
 | 
	
		
			
			| 37 | 37 |  app = Flask(__name__)
 | 
	
		
			
			| 38 | 38 |  app.secret_key = cfg.get('app', 'secret_key')
 | 
	
		
			
			| 39 | 39 |  
 | 
	
		
			
			|  | 40 | +opensearch_xml = '''<?xml version="1.0" encoding="utf-8"?>
 | 
	
		
			
			|  | 41 | +<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
 | 
	
		
			
			|  | 42 | +  <ShortName>searx</ShortName>
 | 
	
		
			
			|  | 43 | +  <Description>Search searx</Description>
 | 
	
		
			
			|  | 44 | +  <InputEncoding>UTF-8</InputEncoding>
 | 
	
		
			
			|  | 45 | +  <LongName>searx meta search engine</LongName>
 | 
	
		
			
			|  | 46 | +  <Url type="text/html" method="post" template="{host}">
 | 
	
		
			
			|  | 47 | +    <Param name="q" value="{{searchTerms}}" />
 | 
	
		
			
			|  | 48 | +  </Url>
 | 
	
		
			
			|  | 49 | +</OpenSearchDescription>
 | 
	
		
			
			|  | 50 | +'''
 | 
	
		
			
			|  | 51 | +
 | 
	
		
			
			| 40 | 52 |  def render(template_name, **kwargs):
 | 
	
		
			
			| 41 | 53 |      kwargs['engines'] = engines.keys()
 | 
	
		
			
			| 42 | 54 |      return render_template(template_name, **kwargs)
 | 
	
	
		
			
			|  | @@ -58,6 +70,19 @@ def index():
 | 
	
		
			
			| 58 | 70 |          return render('results.html', results=results, q=query.decode('utf-8'))
 | 
	
		
			
			| 59 | 71 |      return render('index.html')
 | 
	
		
			
			| 60 | 72 |  
 | 
	
		
			
			|  | 73 | +@app.route('/favicon.ico', methods=['GET'])
 | 
	
		
			
			|  | 74 | +def fav():
 | 
	
		
			
			|  | 75 | +    return ''
 | 
	
		
			
			|  | 76 | +
 | 
	
		
			
			|  | 77 | +@app.route('/opensearch.xml', methods=['GET'])
 | 
	
		
			
			|  | 78 | +def opensearch():
 | 
	
		
			
			|  | 79 | +    global opensearch_xml
 | 
	
		
			
			|  | 80 | +    ret = opensearch_xml.format(host=url_for('index', _external=True))
 | 
	
		
			
			|  | 81 | +    resp = Response(response=ret,
 | 
	
		
			
			|  | 82 | +                status=200,
 | 
	
		
			
			|  | 83 | +                mimetype="application/xml")
 | 
	
		
			
			|  | 84 | +    return resp
 | 
	
		
			
			|  | 85 | +
 | 
	
		
			
			| 61 | 86 |  if __name__ == "__main__":
 | 
	
		
			
			| 62 | 87 |      from gevent import monkey
 | 
	
		
			
			| 63 | 88 |      monkey.patch_all()
 |