This commit is contained in:
Armin Ronacher 2010-07-23 13:03:29 +01:00
parent 8547fdeece
commit 63001a7279
9 changed files with 85 additions and 15 deletions

View file

@ -1,17 +1,14 @@
from flask import Module, render_template, jsonify, request
from flask import Module, render_template, jsonify
from flask_website.utils import request_wants_json
from flask_website.listings.extensions import extensions
mod = Module(__name__, url_prefix='/extensions')
def wants_json():
return request.accept_mimetypes \
.best_match(['application/json', 'text/html']) == 'application/json'
@mod.route('/')
def index():
if wants_json():
return jsonify(extensions=map(vars, extensions))
if request_wants_json():
return jsonify(extensions=[ext.to_json() for ext in extensions])
return render_template('extensions/index.html', extensions=extensions)