Exemple #1
0
def get_image_names():
    if request.method == 'GET':
        image_names = get_all_files_s3(s3_image_bucket())
        if len(image_names) == 0:
            flash('No images')
            return make_response(jsonify({'result': 'no images'}))
        else:
            return jsonify(image_names)
Exemple #2
0
def get_image(image_name):
    if request.method == 'GET':
        if image_name not in get_all_files_s3(s3_image_bucket()):
            flash('Image cannot be found')
            return make_response(jsonify({'result': 'Image cannot be found'}))

        # function from aws_helper.py
        return get_image_url(image_name)
Exemple #3
0
def get_files():
    if request.method == 'GET':
        filenames = get_all_files_s3(s3_file_bucket())
        if len(filenames) == 0:
            flash('No files')
            return make_response(jsonify({'result': 'no files'}))
        else:
            print(filenames)
            return jsonify(filenames)
Exemple #4
0
def delete_file(filename):
    if request.method == 'DELETE':
        if filename not in get_all_files_s3(s3_file_bucket()):
            flash('File does not exist')
            return make_response(jsonify({'result': 'File does not exist.'}))
        output = delete_file_s3(filename, s3_file_bucket())

        return make_response(jsonify(
            {'result': 'success, {}'.format(output)}
        ))
Exemple #5
0
def get_plot(filename):
    if request.method == 'GET':
        if filename not in get_all_files_s3(s3_file_bucket()):
            flash('File does not exist')
            return make_response(jsonify({'result': 'File does not exist.'}))
        file_url = get_file_url(filename)

        image = SIMPLS_Chart(file_url, filename)

        image_file = BytesIO(base64.b64decode(image[22:]))
        upload_file_s3(image_file, s3_image_bucket(), get_signal_name(filename))

        return image