in satellite-app/satellite-flask.py [0:0]
def send_image():
print(dict_image_rekognition)
client = boto3.client('s3')
bucket_name = os.getenv("BUCKET_NAME","space-enablers-poc")
bucket_path = ""
data_path = "static/data"
# images_on_disk = subprocess.check_output(f"ls -l1 static/data", shell=True)
# images_list = list(str(images_on_disk).split("\\n"))[:-1]
random_key = random.choice(key_list)
random_number = random.randrange(0,300)
image_name = dict_image_rekognition.get(random_key)[0]
image_name_rekognition = dict_image_rekognition.get(random_key)[1]
# Removing the key that is already used
dict_image_rekognition.pop(random_key, None)
key_list.remove(random_key)
try:
client.upload_file(f"{data_path}/{image_name}", bucket_name, f"input/{random_number}{image_name}")
return render_template("satellite_return.html", image_path=f"/{data_path}/{image_name}", image_path_rekognition=f"/{data_path}/{image_name_rekognition}")
except Exception as e:
raise e