From 6871bfd3bfd796dcbae8da46450344b4856fa616 Mon Sep 17 00:00:00 2001 From: Jan-Pieter Baert Date: Wed, 13 Feb 2019 22:02:14 +0100 Subject: [PATCH] fixed that when the person isn't in the queue the site doesn't crash --- main.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index b9fd26f..f209a9c 100644 --- a/main.py +++ b/main.py @@ -44,11 +44,13 @@ def home(): @app.route("/statusUpdate", methods=["POST", "GET"]) def statusUpdate(): if people and request.method == "POST": - index = people.index(Person(request.form["name"])) - print(index) - people[index].status += 1 - if people[index].status == 3: - people.remove(people[index]) + newPerson = Person(request.form["name"]) + if newPerson in people: + index = people.index(newPerson) + print(index) + people[index].status += 1 + if people[index].status == 3: + people.remove(people[index]) return redirect("/")