changes in service

This commit is contained in:
2021-01-15 12:22:40 +01:00
parent 9717d171bf
commit 124fca001a
3 changed files with 108 additions and 2 deletions

View File

@ -11,6 +11,9 @@ HEROES = [
]
def get_heroes():
if HEROES:
return HEROES
@ -27,6 +30,9 @@ def get_hero(id=None):
def put_hero(id=None, hero=None):
try:
heroToUpdate = next(x for x in HEROES if x["id"] == id)
checkNewName = next((x for x in HEROES if x["name"] == hero["name"]), None)
if (checkNewName):
return 'Duplicate name', 403
heroToUpdate["name"] = hero["name"]
return 'Hero updated', 200
except StopIteration: