Files
WebApi/webapi/blueprints/cacu.py
T
Roberto Treviño Cervantes c1444e2b8d initial commit
2026-09-21 10:23:40 -06:00

26 lines
793 B
Python

from flask import Blueprint, jsonify
from models.cacu import CaCuModel
from persistance.cacu import paciente_repository
cacu_bp = Blueprint("cacu", __name__)
@cacu_bp.get("/pacientes/<int:pac_id>")
def get_paciente(pac_id: int):
"""Example read route — proves WebApi resolves Persistance's repository API."""
paciente = paciente_repository.get(pac_id)
if paciente is None:
return jsonify({"error": "not found"}), 404
return jsonify(paciente.model_dump())
@cacu_bp.post("/predict")
def predict():
"""Example predict route — proves WebApi resolves the models package."""
model = CaCuModel()
try:
return jsonify({"prediction": model.predict(data=None)})
except NotImplementedError as exc:
return jsonify({"error": str(exc)}), 501