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')
评论列表
文章目录