Skip to content

Instantly share code, notes, and snippets.

@felixzhooou
felixzhooou / jsonp.py
Created April 14, 2017 09:17
JSONP decorator based on Flask
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'
@felixzhooou
felixzhooou / bobp-python.md
Created April 14, 2017 01:40 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens