diff --git a/consumer_api/views/consumers_view.py b/consumer_api/views/consumers_view.py index feb59ef..c12739c 100644 --- a/consumer_api/views/consumers_view.py +++ b/consumer_api/views/consumers_view.py @@ -1,7 +1,12 @@ +import json + +from db import redis_client +from flask import jsonify from flask_classful import FlaskView class ConsumersView(FlaskView): def get(self): - return "ConsumersView" + consumer_list = json.loads((redis_client.get("consumer_list") or b"{}").decode('utf-8')) + return jsonify([v['ip'] for k, v in consumer_list.items()]) diff --git a/consumer_api/views/log_view.py b/consumer_api/views/log_view.py index fc589f4..abfff93 100644 --- a/consumer_api/views/log_view.py +++ b/consumer_api/views/log_view.py @@ -1,7 +1,9 @@ +from flask import request, current_app, Response from flask_classful import FlaskView class LogView(FlaskView): - def get(self): - return "LogView" \ No newline at end of file + def post(self): + current_app.logger.info(f"New message: {request.json['message']}") + return Response(status = 204)