from pathlib import Path from flask import Flask import random def get_all_images(current_app: Flask): images = [] photos_dir = Path(f"{current_app.static_folder}/photos") for file_path in photos_dir.rglob("*"): if file_path.is_file(): img_path = file_path.relative_to(current_app.static_folder) images.append(str(img_path)) print(f"Returning {len(images)} images") shuffled = random.sample(list(images), k=len(images)) return shuffled