Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
paolofraccaro committed May 22, 2024
1 parent dcaf90e commit 6d80dfb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions service/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
12 changes: 9 additions & 3 deletions service/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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

Expand All @@ -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)
Expand Down

0 comments on commit 6d80dfb

Please sign in to comment.