struct
This commit is contained in:
27
routes/unsecure_routes.py
Normal file
27
routes/unsecure_routes.py
Normal file
@@ -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})
|
||||
27
server.py
27
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)
|
||||
|
||||
Reference in New Issue
Block a user