import os from flask import Blueprint, current_app, send_file, abort bp = Blueprint("proxy", __name__) @bp.route("/thumb/") def thumb(asset_id): cfg = current_app.config["APP_CONFIG"] safe = os.path.basename(asset_id) path = os.path.join(cfg.thumbs_dir, f"{safe}.jpg") if not os.path.exists(path): abort(404) return send_file(path, mimetype="image/jpeg")