예제 #1
0
def get_image(filename):
    try:
        UserRequest.tsne_filename_nonexistence_validator(filename)
    except Exception as invalid_tsne_filename:
        return (
            jsonify(
                {MESSAGE_RESULT: invalid_tsne_filename.args[FIRST_ARGUMENT]}),
            HTTP_STATUS_CODE_NOT_FOUND,
        )

    image_path = os.environ[IMAGES_PATH] + "/" + filename + IMAGE_FORMAT

    return send_file(image_path, mimetype="image/png")
예제 #2
0
def delete_image(filename):
    try:
        UserRequest.tsne_filename_nonexistence_validator(filename)
    except Exception as invalid_tsne_filename:
        return (
            jsonify(
                {MESSAGE_RESULT: invalid_tsne_filename.args[FIRST_ARGUMENT]}),
            HTTP_STATUS_CODE_NOT_FOUND,
        )

    image_path = os.environ[IMAGES_PATH] + "/" + filename + IMAGE_FORMAT

    thread_pool.submit(os.remove, image_path)

    return jsonify({MESSAGE_RESULT:
                    MESSAGE_DELETED_FILE}), HTTP_STATUS_CODE_SUCCESS