diff --git a/service/__init__.py b/service/__init__.py index ca30cf9..1875e0f 100644 --- a/service/__init__.py +++ b/service/__init__.py @@ -6,8 +6,8 @@ app = Flask(__name__) # This must be imported after the Flask app is created -from service import routes -from service.common import log_handlers +from service import routes +from service.common import log_handlers log_handlers.init_logging(app, "gunicorn.error") diff --git a/service/routes.py b/service/routes.py index f8cfa34..7f94c8f 100644 --- a/service/routes.py +++ b/service/routes.py @@ -40,7 +40,11 @@ def list_counters(): """Lists all counters""" app.logger.info("Request to list all counters...") - counters = [dict(name=count[0], counter=count[1]) for count in COUNTER.items()] + counters = [] + for count in COUNTER.items(): + counters.append(dict(name=count[0], counter=count[1])) + # counters = [dict(name=count[0], counter=count[1]) + # for count in COUNTER.items()] return jsonify(counters) @@ -54,7 +58,8 @@ def create_counters(name): app.logger.info("Request to Create counter: %s...", name) if name in COUNTER: - return abort(status.HTTP_409_CONFLICT, f"Counter {name} already exists") + output_string=f"Counter {name} already exists" + return abort(status.HTTP_409_CONFLICT, output_string) COUNTER[name] = 0 @@ -75,7 +80,8 @@ def read_counters(name): app.logger.info("Request to Read counter: %s...", name) if name not in COUNTER: - return abort(status.HTTP_404_NOT_FOUND, f"Counter {name} does not exist") + output_string=f"Counter {name} does not exist" + return abort(status.HTTP_404_NOT_FOUND, output_string) counter = COUNTER[name] return jsonify(name=name, counter=counter)