import os
import datetime
from flask import Blueprint, request, jsonify, send_from_directory
from PIL import Image
from ultralytics import YOLO
from config import IMAGE_FOLDER

show_bp = Blueprint('show', __name__)

@show_bp.route('/images/<date>/<filename>')
def get_image(date, filename):
    image_path = os.path.join("images", date)

    if not os.path.exists(image_path):
        return jsonify({"error": "Image not found"}), 404

    return send_from_directory(image_path, filename)