initial commit

This commit is contained in:
Roberto Treviño Cervantes
2026-09-21 10:23:40 -06:00
commit c1444e2b8d
11 changed files with 220 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
from flask import Flask
from webapi.blueprints.cacu import cacu_bp
from webapi.blueprints.cama import cama_bp
from webapi.blueprints.tea import tea_bp
def create_app() -> Flask:
app = Flask(__name__)
@app.get("/health")
def health():
return {"status": "ok"}
app.register_blueprint(cacu_bp, url_prefix="/cacu")
app.register_blueprint(cama_bp, url_prefix="/cama")
app.register_blueprint(tea_bp, url_prefix="/tea")
return app
View File
+25
View File
@@ -0,0 +1,25 @@
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
+23
View File
@@ -0,0 +1,23 @@
from flask import Blueprint, jsonify
from models.cama import CaMaModel
from persistance.cama import paciente_repository
cama_bp = Blueprint("cama", __name__)
@cama_bp.get("/pacientes/<int:pac_id>")
def get_paciente(pac_id: int):
paciente = paciente_repository.get(pac_id)
if paciente is None:
return jsonify({"error": "not found"}), 404
return jsonify(paciente.model_dump())
@cama_bp.post("/predict")
def predict():
model = CaMaModel()
try:
return jsonify({"prediction": model.predict(data=None)})
except NotImplementedError as exc:
return jsonify({"error": str(exc)}), 501
+23
View File
@@ -0,0 +1,23 @@
from flask import Blueprint, jsonify
from models.tea import TeaModel
from persistance.tea import pacientes_repository
tea_bp = Blueprint("tea", __name__)
@tea_bp.get("/pacientes/<string:pac_id>")
def get_paciente(pac_id: str):
paciente = pacientes_repository.get(pac_id)
if paciente is None:
return jsonify({"error": "not found"}), 404
return jsonify(paciente.model_dump())
@tea_bp.post("/predict")
def predict():
model = TeaModel()
try:
return jsonify({"prediction": model.predict(data=None)})
except NotImplementedError as exc:
return jsonify({"error": str(exc)}), 501