import json
from flask import Response


def build_response(output, status=200, mimetype='application/json',
                   headers={}):
    return Response(
        json.dumps(output),
        mimetype=mimetype
    ), status, headers

import json
from flask import Response, jsonify


def build_response(output, status=200, mimetype='application/json',
                   headers={}):
    resp = jsonify(output)
    resp.mimetype = mimetype
    return resp, status, headers

Fix issue with datetime handling
Fix issue with datetime handling
