-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
26 lines (21 loc) · 767 Bytes
/
app.py
File metadata and controls
26 lines (21 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from flask import Flask, render_template, redirect, url_for
app = Flask(__name__)
# creating 12 desks with mixed initial status for a realistic look
tables = []
for i in range(1, 13):
# odd numbers start open (green), even numbers start busy (red)
status = "Full" if i % 2 == 0 else "Empty"
tables.append({"no": i, "status": status})
@app.route('/')
def index():
return render_template('index.html', tables=tables)
@app.route('/toggle/<int:no>')
def toggle(no):
# logic to switch desk status on click
for table in tables:
if table['no'] == no:
table['status'] = "Full" if table['status'] == "Empty" else "Empty"
break
return redirect(url_for('index'))
if __name__ == '__main__':
app.run(debug=True)