def get(): id = request.args.get('id') if not (id and ObjectId.is_valid(id)): abort(400) result = get_template(ObjectId(id)) if not result: return Response(status=404) obj = convert_template_from_mongo(result) response_data = json.dumps(obj) logger.debug('--response_data--' + response_data) resp = Response(response=response_data, status=201, content_type='application/json') return resp
def create(): request_data = request.json logger.debug('--request_data--' + str(request_data)) storage_id = request_data.get('storage_id') if not storage_id: abort(400) result = create_template(request_data) if not result: return Response(status=500) obj = convert_template_from_mongo(result) response_data = json.dumps(obj) logger.debug('--response_data--' + response_data) resp = Response(response=response_data, status=201, content_type='application/json') return resp