@@ -40,7 +40,11 @@ def list_counters():
40
40
"""Lists all counters"""
41
41
app .logger .info ("Request to list all counters..." )
42
42
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()]
44
48
45
49
return jsonify (counters )
46
50
@@ -54,7 +58,8 @@ def create_counters(name):
54
58
app .logger .info ("Request to Create counter: %s..." , name )
55
59
56
60
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 )
58
63
59
64
COUNTER [name ] = 0
60
65
@@ -75,7 +80,8 @@ def read_counters(name):
75
80
app .logger .info ("Request to Read counter: %s..." , name )
76
81
77
82
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 )
79
85
80
86
counter = COUNTER [name ]
81
87
return jsonify (name = name , counter = counter )
0 commit comments