From e807f83375e4f2c8b74658b22cf96e5a331f7409 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Fri, 25 Sep 2015 19:36:44 +0300 Subject: Added shortcuts --- servo/lib/utils.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'servo/lib/utils.py') diff --git a/servo/lib/utils.py b/servo/lib/utils.py index a6b9e78..f2e0c21 100644 --- a/servo/lib/utils.py +++ b/servo/lib/utils.py @@ -1,15 +1,28 @@ # -*- coding: utf-8 -*- import json +import subprocess from django.db.models import Model +from django.http import HttpResponse from django.core.serializers.json import DjangoJSONEncoder +def csv_response(data): + """ + Shortcut for sending a CSV response + """ + return HttpResponse(data, content_type='text/csv') + +def json_response(data): + """ + Shortcut for sending a JSON response + """ + return HttpResponse(json.dumps(data), content_type='application/json') + def strip_keypass(keypass, infile, outfile): """ Strips a passphrase from a private key """ - import subprocess subprocess.call(['openssl', 'rsa', '-passin', 'pass:' + keypass, '-in', infile, '-out', outfile]) -- cgit v1.2.3