flask/flask_website/views/extensions.py
2010-07-23 11:48:31 +01:00

20 lines
583 B
Python

from flask import Module, render_template, jsonify, request
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))
return render_template('extensions/index.html', extensions=extensions)
@mod.route('/creating/')
def creating():
return render_template('extensions/creating.html')