A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
def jsonp(func): | |
"""Wraps JSONified output for JSONP requests.""" | |
@wraps(func) | |
def decorated_function(*args, **kwargs): | |
callback = request.args.get('callback', False) | |
if callback: | |
data = str(func(*args, **kwargs).data) | |
content = str(callback) + '(' + data + ')' | |
print(content) | |
mimetype = 'application/javascript' |