27 lines
668 B
Python
27 lines
668 B
Python
from flask import Flask, render_template, request, jsonify
|
|
import json, os
|
|
|
|
app = Flask(__name__)
|
|
DATEI = os.path.join(os.path.dirname(__file__), "sitzplan.json") # relativ zum Skript
|
|
|
|
|
|
def lade():
|
|
with open(DATEI, "r", encoding="utf-8") as f:
|
|
return json.load(f)
|
|
|
|
|
|
@app.route("/")
|
|
def home():
|
|
return render_template("index.html", data=lade())
|
|
|
|
|
|
@app.route("/speichern", methods=["POST"])
|
|
def speichern():
|
|
daten = request.get_json()
|
|
with open(DATEI, "w", encoding="utf-8") as f:
|
|
json.dump(daten, f, ensure_ascii=False, indent=2)
|
|
return jsonify({"status": "ok"})
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app.run(host="0.0.0.0", port=5000)
|