跳转到主要内容

为django提供简单的JSONP支持

项目描述

为django提供简单的JSONP支持

Coverage Status Build Status PyPI version Scrutinizer Code Quality Code Health

安装

使用pip安装...

$ pip install django-jsonp

用法

from djsonp import jsonp, JSONPResponse, get_callback

# decorate something that returns a dict-like object
@jsonp
def my_view(request):
    return {'foo': 'bar'}


# it can work with an HttpResponse instances
@jsonp
def another_view(request):
    return HttpResponse("{'foo': 'bar'}")

# or just return a JSONPResponse
def jsonp_view(request):
    return JSONPResponse(data={'foo': 'bar', }, callback=get_callback(request))

# it also works for CBVs
from django.views.generic import View

@jsonp
class DictResponse(View):
    def get(self, request):
        return HttpResponse("{'foo': 'bar'}")

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分布

django_jsonp-0.3.0.tar.gz (2.8 kB 查看哈希值)

上传时间:

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面