summaryrefslogtreecommitdiff
path: root/searx/webapp.py
diff options
context:
space:
mode:
authorasciimoo <asciimoo@gmail.com>2013-10-17 00:30:41 +0200
committerasciimoo <asciimoo@gmail.com>2013-10-17 00:30:41 +0200
commit3d8b7ea3ea100a72a0a18c9161cf688d6586f8f0 (patch)
tree363e39d26b281053bc25a6b084cc84920db18a6a /searx/webapp.py
parente467a24843b62ff444b20e81a7b22b0cc5783a9e (diff)
[enh] json output support
Diffstat (limited to 'searx/webapp.py')
-rw-r--r--searx/webapp.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/searx/webapp.py b/searx/webapp.py
index afd7d19ca..02fb92058 100644
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -26,6 +26,7 @@ from flask import Flask, request, flash, render_template, url_for, Response
import ConfigParser
from os import getenv
from searx.engines import search, engines
+import json
cfg = ConfigParser.SafeConfigParser()
cfg.read('/etc/searx.conf')
@@ -67,6 +68,9 @@ def index():
selected_engines = engines.keys()
query = request.form['q'].encode('utf-8')
results = search(query, request, selected_engines)
+ if request.form.get('format') == 'json':
+ # TODO HTTP headers
+ return json.dumps({'query': query, 'results': results})
return render('results.html', results=results, q=query.decode('utf-8'))
return render('index.html')