from flask import Flask, render_template, request, redirect, url_for app = Flask(__name__) class Person: statusses = ["Pannenkoek besteld", "Pannenkoek aan het bakken", "Pannenkoek klaar", "Pannenkoek afgegeven"] def __init__(self, name, remark=""): self.name = name self.remark = remark.strip() self.status = 0 def getRemark(self): return "({})".format(self.remark) if self.remark else self.remark def getName(self): return self.name def __eq__(self, other): return self.name == other.name def getStatus(self): return self.statusses[self.status] def nextStatus(self): return self.statusses[self.status + 1] def __str__(self): return "Persoon: {} met status: {}".format(self.name, self.status) def __repr__(self): return str(self) people = [] @app.route("/") def home(): return render_template("home.html", people=people) @app.route("/statusUpdate") def statusUpdate(): if people: people[0].status += 1 if people[0].status == 3: people.remove(people[0]) return redirect("/") @app.route("/addPerson", methods=["POST", "GET"]) def addPerson(): if request.method == "POST": result = request.form newPerson = Person(request.form["name"], request.form["remark"]) if newPerson not in people: people.append(newPerson) return redirect("/") if __name__ == "__main__": app.run()