This commit is contained in:
2021-01-14 12:51:40 +01:00
parent d4caaae0f2
commit 9570bef24d
15 changed files with 142 additions and 633 deletions

29
tools/ws/heroes.py Normal file
View File

@ -0,0 +1,29 @@
HEROES = [
{ "id": 1, "name": "Wolfgang" },
{ "id": 2, "name": "Andreas" },
{ "id": 3, "name": "Frank" },
{ "id": 4, "name": "Thomas" },
{ "id": 5, "name": "Barbara" },
{ "id": 6, "name": "Robert" },
{ "id": 7, "name": "Raphael" },
{ "id": 8, "name": "Lucia" },
{ "id": 9, "name": "Gregor" },
]
def get_hero(id=None):
if id:
try:
hero = next(x for x in HEROES if x["id"] == id)
return { "id": hero["id"], "name": hero["name"] }
except StopIteration:
return 'Hero not found', 404
def get_heroes():
if HEROES:
return HEROES
else:
return 'No heroes available', 404