parameters.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:cjworkbench 作者: CJWorkbench 项目源码 文件源码
def parameterval_png(request, pk):
    try:
        param = ParameterVal.objects.get(pk=pk)
    except ParameterVal.DoesNotExist:
        return HttpResponseNotFound()

    if not param.wf_module.public_authorized():
        return HttpResponseForbidden()

    # is this actually in image? totes hardcoded for now
    if param.parameter_spec.id_name != 'chart':
        return HttpResponseBadRequest()

    # decode the base64 payload of the data URI into a png
    image_data = param.value.partition('base64,')[2]
    binary = base64.b64decode(image_data)
    return HttpResponse(binary, content_type='image/png')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号