From 0e3cb2eed63db29b8a16d864855ee777548166c2 Mon Sep 17 00:00:00 2001 From: Augusto Gunsch Date: Sun, 17 Oct 2021 19:15:56 -0300 Subject: [PATCH] Adicionar endpoint: GET /trainer/{trainerId} --- api/routes/routes.py | 4 ++++ api/views/trainer.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/api/routes/routes.py b/api/routes/routes.py index b322a4e..be7686c 100644 --- a/api/routes/routes.py +++ b/api/routes/routes.py @@ -3,6 +3,10 @@ from sqlite3 import ProgrammingError, IntegrityError from api.app import app, db from api.views import trainer +@app.route('/trainer/', methods=['GET']) +def route_get_trainer(trainerId): + return trainer.get_trainer(trainerId) + @app.route('/trainer', methods=['GET']) def route_get_trainers(): return trainer.get_trainers() diff --git a/api/views/trainer.py b/api/views/trainer.py index fa56982..0829bf3 100644 --- a/api/views/trainer.py +++ b/api/views/trainer.py @@ -11,6 +11,9 @@ def error(code, type, message, http_code=400): "message": message }, http_code) +def get_trainer(id): + return trainer_schema.dump(Trainer.query.get(id)) + def get_trainers(): args = request.args