From ff9cdf196933ea14579cec22cd7964af57a8e45f Mon Sep 17 00:00:00 2001 From: derlole <122916573+derlole@users.noreply.github.com> Date: Tue, 15 Apr 2025 08:50:24 +0000 Subject: [PATCH] struct --- .../Schaltplan}/Schaltplan.pdf | Bin .../Datenblatt_RPS42730_230V_Relais.pdf | Bin routes/unsecure_routes.py | 27 ++++++++++++++++++ server.py | 27 ++++-------------- 4 files changed, 32 insertions(+), 22 deletions(-) rename {Schaltplan => aaaSonstiges/Schaltplan}/Schaltplan.pdf (100%) rename {datenblaetter => aaaSonstiges/datenblaetter}/Datenblatt_RPS42730_230V_Relais.pdf (100%) create mode 100644 routes/unsecure_routes.py diff --git a/Schaltplan/Schaltplan.pdf b/aaaSonstiges/Schaltplan/Schaltplan.pdf similarity index 100% rename from Schaltplan/Schaltplan.pdf rename to aaaSonstiges/Schaltplan/Schaltplan.pdf diff --git a/datenblaetter/Datenblatt_RPS42730_230V_Relais.pdf b/aaaSonstiges/datenblaetter/Datenblatt_RPS42730_230V_Relais.pdf similarity index 100% rename from datenblaetter/Datenblatt_RPS42730_230V_Relais.pdf rename to aaaSonstiges/datenblaetter/Datenblatt_RPS42730_230V_Relais.pdf diff --git a/routes/unsecure_routes.py b/routes/unsecure_routes.py new file mode 100644 index 0000000..8bc67d3 --- /dev/null +++ b/routes/unsecure_routes.py @@ -0,0 +1,27 @@ +from flask import Blueprint, render_template, request, jsonify + +unsecure = Blueprint('unsecure', __name__, url_prefix='/unsecure') + +pending_command = None + +@unsecure.route('/') +def index(): + return render_template('index.html') + +@unsecure.route('/send') +def send_command(): + global pending_command + befehl = request.args.get('befehl') + if befehl: + pending_command = befehl + return f"Befehl '{befehl}' gespeichert." + return "Kein Befehl angegeben.", 400 + +@unsecure.route('/fetch') +def fetch_command(): + global pending_command + if pending_command: + cmd = pending_command + pending_command = None + return jsonify({'befehl': cmd}) + return jsonify({'befehl': None}) diff --git a/server.py b/server.py index 7cebd93..ae50e7b 100644 --- a/server.py +++ b/server.py @@ -1,28 +1,11 @@ -from flask import render_template, Flask, request, jsonify + +from flask import Flask +from routes.unsecure_routes import unsecure app = Flask(__name__, static_url_path='/unsecure/static') -pending_command = None -@app.route('/unsecure') -def index(): - return render_template('index.html') # Lädt templates/index.html +# Blueprint registrieren +app.register_blueprint(unsecure) -@app.route('/unsecure/send') -def send_command(): - global pending_command - befehl = request.args.get('befehl') - if befehl: - pending_command = befehl - return f"Befehl '{befehl}' gespeichert." - return "Kein Befehl angegeben.", 400 - -@app.route('/unsecure/fetch') -def fetch_command(): - global pending_command - if pending_command: - cmd = pending_command - pending_command = None - return jsonify({'befehl': cmd}) - return jsonify({'befehl': None}) if __name__ == '__main__': app.run(host='0.0.0.0', port=3060)