Przeglądaj źródła

[enh] optionally configurable hostname - edit settings.py

asciimoo 11 lat temu
rodzic
commit
141b04c6dd
2 zmienionych plików z 7 dodań i 1 usunięć
  1. 2
    0
      searx/settings.py
  2. 5
    1
      searx/webapp.py

+ 2
- 0
searx/settings.py Wyświetl plik

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

+ 5
- 1
searx/webapp.py Wyświetl plik

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