from flask import Blueprint, request, jsonify
from services import FileService

file_bp = Blueprint("file", __name__)

@file_bp.route("/get", methods=["GET"])
def file_get():
    data = request.json
    file_handle = data["file_handle"]
    file = FileService.get_file_by_file_handle(file_handle)
    if not file:
        return jsonify({"error": "File not found"}), 404
    return jsonify(file.to_dict()), 200