This repository has been archived on 2020-09-24. You can view files and clone it, but cannot push or open issues or pull requests.
consumer-api/consumer_api/views/consumers_view.py

19 lines
563 B
Python
Raw Normal View History

2020-03-30 16:32:33 +02:00
import json
2020-03-30 17:00:59 +02:00
2020-03-30 16:32:33 +02:00
from db import redis_client
from flask import jsonify, request
2020-03-29 17:08:53 +02:00
from flask_classful import FlaskView
class ConsumersView(FlaskView):
def get(self):
2020-04-04 13:53:26 +02:00
# load the currently available consumer list from the redis database
2020-03-30 16:32:33 +02:00
consumer_list = json.loads((redis_client.get("consumer_list") or b"{}").decode('utf-8'))
2020-04-04 13:53:26 +02:00
# jsonify and return the list of active consumers
if 'full' in request.args:
return jsonify(consumer_list)
else:
return jsonify([v['ip'] for k, v in consumer_list.items()])