initial commit
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user