Browse Source

[enh] optionally configurable hostname - edit settings.py

asciimoo 11 years ago
parent
commit
141b04c6dd
2 changed files with 7 additions and 1 deletions
  1. 2 0
      searx/settings.py
  2. 5 1
      searx/webapp.py

+ 2 - 0
searx/settings.py

@@ -12,3 +12,5 @@ weights = {} # 'search_engine_name': float(weight) | default is 1.0
 blacklist = [] # search engine blacklist
 blacklist = [] # search engine blacklist
 
 
 categories = {} # custom search engine categories
 categories = {} # custom search engine categories
+
+hostname = None # domain name or None - if you want to rewrite the default HTTP host

+ 5 - 1
searx/webapp.py

@@ -165,7 +165,11 @@ def opensearch():
         method = 'get'
         method = 'get'
     if request.is_secure:
     if request.is_secure:
         scheme = 'https'
         scheme = 'https'
-    ret = opensearch_xml.format(method=method, host=url_for('index', _external=True, _scheme=scheme))
+    if settings.hostname:
+        hostname = '{0}://{1}/'.format(scheme,settings.hostname)
+    else:
+        hostname = url_for('index', _external=True, _scheme=scheme)
+    ret = opensearch_xml.format(method=method, host=hostname)
     resp = Response(response=ret,
     resp = Response(response=ret,
                 status=200,
                 status=200,
                 mimetype="application/xml")
                 mimetype="application/xml")