Added support for retreiving extensions as JSON
This commit is contained in:
parent
7a058c667b
commit
8547fdeece
1 changed files with 7 additions and 1 deletions
|
|
@ -1,11 +1,17 @@
|
|||
from flask import Module, render_template
|
||||
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)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue