コード例 #1
0
def get_image(filename):
    try:
        UserRequest.pca_filename_nonexistence_validator(filename)

    except Exception as invalid_pca_filename:
        return (
            jsonify(
                {MESSAGE_RESULT: invalid_pca_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.pca_filename_nonexistence_validator(filename)
    except Exception as invalid_pca_filename:
        return (
            jsonify(
                {MESSAGE_RESULT: invalid_pca_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