Commit b2490eac authored by jan-pieter's avatar jan-pieter

added initial very ugly version, it works...

parent 0ccb204d
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()
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Pannenkoekenwachtrij</title>
</head>
<body>
<header>
<h1>Welkom bij de pannenkoekenwachtrij</h1>
<form action="/addPerson" method="POST">
<p>Naam van de volgende <input type="text" name="name"></p>
<p>Specifieke opmerkingen <input type="text" name="remark"></p>
<p><input type="submit" value="Persoon toevoegen"></p>
</form>
<h2>Zie hieronder de lijst van personen die een pannenkoek willen</h2>
<table>
{% for person in people %}
<tr>
<th>{{ person.getName() + person.getRemark() + ": " }}</th>
<td>
<a href="/statusUpdate">
<input type="button" value="{{ person.nextStatus() }}"/>
</a>
</td>
<td>{{ "Huidige status: " + person.getStatus() }}</td>
</tr>
{% endfor %}
</table>
</header>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment