Skip to content

Commit 6d80dfb

Browse files
committed
fix
1 parent dcaf90e commit 6d80dfb

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

service/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
app = Flask(__name__)
77

88
# This must be imported after the Flask app is created
9-
from service import routes
10-
from service.common import log_handlers
9+
from service import routes
10+
from service.common import log_handlers
1111

1212
log_handlers.init_logging(app, "gunicorn.error")
1313

service/routes.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ def list_counters():
4040
"""Lists all counters"""
4141
app.logger.info("Request to list all counters...")
4242

43-
counters = [dict(name=count[0], counter=count[1]) for count in COUNTER.items()]
43+
counters = []
44+
for count in COUNTER.items():
45+
counters.append(dict(name=count[0], counter=count[1]))
46+
# counters = [dict(name=count[0], counter=count[1])
47+
# for count in COUNTER.items()]
4448

4549
return jsonify(counters)
4650

@@ -54,7 +58,8 @@ def create_counters(name):
5458
app.logger.info("Request to Create counter: %s...", name)
5559

5660
if name in COUNTER:
57-
return abort(status.HTTP_409_CONFLICT, f"Counter {name} already exists")
61+
output_string=f"Counter {name} already exists"
62+
return abort(status.HTTP_409_CONFLICT, output_string)
5863

5964
COUNTER[name] = 0
6065

@@ -75,7 +80,8 @@ def read_counters(name):
7580
app.logger.info("Request to Read counter: %s...", name)
7681

7782
if name not in COUNTER:
78-
return abort(status.HTTP_404_NOT_FOUND, f"Counter {name} does not exist")
83+
output_string=f"Counter {name} does not exist"
84+
return abort(status.HTTP_404_NOT_FOUND, output_string)
7985

8086
counter = COUNTER[name]
8187
return jsonify(name=name, counter=counter)

0 commit comments

Comments
 (0)