summaryrefslogtreecommitdiff
path: root/cli/app/server/representations.py
blob: 76d9ed4536f5969f45fe851b81ba9e82a995948c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
import simplejson as json
from flask import make_response

def output_json(data, code, headers=None):
  content_type = 'application/json'
  dumped = json.dumps(data)
  if headers:
    headers.update({'Content-Type': content_type})
  else:
    headers = {'Content-Type': content_type}
  response = make_response(dumped, code, headers)
  return response