drime

French rhyme dictionary with web and CLI interface
git clone https://a3nm.net/git/drime/
Log | Files | Refs | README

commit 880aa553ab1301a7d08145c7da81bc755f326fff
parent 9065f006d25de52dff4e1ad407c7ff5cc4e9175f
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Tue, 27 Dec 2011 03:38:57 +0100

more json

Diffstat:
drime.py | 9+++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drime.py b/drime.py @@ -36,21 +36,26 @@ def q(): d['displayed'] = min(d['pagesize'], count) d['keys'] = sorted(r.keys()) if len(r.keys()) == 0: + if request.args.get('json'): + return jsonify(d) return render_template('notfound.html', **d) elif len(r.keys()) > 1: #d['example'] = {} #for k in d['keys']: #d['example'][k] = r[k] + if request.args.get('json'): + return jsonify(d) return render_template('disambig.html', **d) else: d['result'] = r[r.keys()[0]] # TODO better if request.args.get('json'): return jsonify(d) - else: - return render_template('results.html', **d) + return render_template('results.html', **d) except query.BadValues: d['mode'] = 'query' + if request.args.get('json'): + return jsonify(d) return render_template('error.html', **d) if __name__ == '__main__':