logo

searx

My custom branche(s) on searx, a meta-search engine
commit: 3d8b7ea3ea100a72a0a18c9161cf688d6586f8f0
parent: e467a24843b62ff444b20e81a7b22b0cc5783a9e
Author: asciimoo <asciimoo@gmail.com>
Date:   Thu, 17 Oct 2013 00:30:41 +0200

[enh] json output support

Diffstat:

Msearx/webapp.py4++++
1 file changed, 4 insertions(+), 0 deletions(-)

diff --git 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')