Projekt entpackt + Fix: app.py (statt app.py.py); index.html rendert Sitzplan aus sitzplan.json (Jinja-Schleife, zeigt auch nachricht)
This commit is contained in:
parent
f1f678bb41
commit
6c94f6595c
4 changed files with 97 additions and 0 deletions
BIN
Projekt.7z
BIN
Projekt.7z
Binary file not shown.
21
Projekt/app.py
Normal file
21
Projekt/app.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
from flask import Flask, render_template
|
||||
import json
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
@app.route("/")
|
||||
def home():
|
||||
|
||||
# Sitzplan-Datei öffnen
|
||||
with open("sitzplan.json", "r", encoding="utf-8") as datei:
|
||||
sitzplan = json.load(datei)
|
||||
|
||||
return render_template(
|
||||
"index.html",
|
||||
sitzplan=sitzplan
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0", port=5000)
|
||||
27
Projekt/sitzplan.json
Normal file
27
Projekt/sitzplan.json
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
[
|
||||
{
|
||||
"platz": "platz01",
|
||||
"name": "Max",
|
||||
"nachricht": ""
|
||||
},
|
||||
{
|
||||
"platz": "platz02",
|
||||
"name": "Lea",
|
||||
"nachricht": ""
|
||||
},
|
||||
{
|
||||
"platz": "platz03",
|
||||
"name": "Tim",
|
||||
"nachricht": ""
|
||||
},
|
||||
{
|
||||
"platz": "platz04",
|
||||
"name": "Ben",
|
||||
"nachricht": ""
|
||||
},
|
||||
{
|
||||
"platz": "platz05",
|
||||
"name": "Eva",
|
||||
"nachricht": ""
|
||||
}
|
||||
]
|
||||
49
Projekt/templates/index.html
Normal file
49
Projekt/templates/index.html
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Sitzplan</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, 120px);
|
||||
gap: 10px;
|
||||
justify-content: center;
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
.seat {
|
||||
border: 2px solid black;
|
||||
padding: 20px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.seat .nachricht {
|
||||
margin-top: 8px;
|
||||
color: #2563eb;
|
||||
font-size: 0.85em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h1>Sitzplan</h1>
|
||||
|
||||
<div class="grid">
|
||||
{% for platz in sitzplan %}
|
||||
<div class="seat">
|
||||
{{ platz.name }}
|
||||
{% if platz.nachricht %}
|
||||
<div class="nachricht">{{ platz.nachricht }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in a new issue