Example #1
0
def multivdu_blueprint():
    if request.method == 'POST':
        print "Received POST request to generate Multi-VDU Blueprint with data= {}".format(
            request.data)
        print "We arrived correct"
        inputs = json.loads(request.data)
        print "inputs:", inputs
        inputs['username'] = request.headers['Username']
        inputs['session_key'] = request.headers['Authorization']
        print "inputs:", inputs
        #multivdu_inputs = convert_payload_to_json(inputs)
        output_file, workdir = create_multivdu_blueprint_package(inputs)
        resp = send_from_directory(
            directory=os.path.dirname(workdir),
            filename=os.path.basename(output_file),
            as_attachment=True,
            attachment_filename=os.path.basename(output_file))
        cleanup(os.path.dirname(workdir))
        return resp
        #print "output_file = {},workdir = {}".format(output_file,workdir)
        #resp = output_file
        #cleanup(os.path.dirname(workdir))
        #return resp
    else:
        print "Invalid request. Has to be POST"
        return
Example #2
0
def generate():
    inputs = request.get_json()
    print("Inputs Received: %s\n", inputs)
    pprint.pprint(request.headers)
    pprint.pprint(request.headers['Authorization'])
    pprint.pprint(request.headers['Username'])
    inputs['params']['username'] = request.headers['Username']
    inputs['params']['session_key'] = request.headers['Authorization']
    output_file, workdir = create_blueprint_package(inputs)
    print("backend:workdir=%s\n", workdir)
    resp = send_from_directory(
        directory=os.path.dirname(workdir),
        filename=os.path.basename(output_file),
        as_attachment=True,
        attachment_filename=os.path.basename(output_file))
    cleanup(os.path.dirname(workdir))
    return resp