init py server

This commit is contained in:
derlole
2025-04-14 08:29:20 +00:00
parent fb5df93da5
commit 7e8b74ffd4
5 changed files with 94 additions and 1 deletions

29
server.py Normal file
View File

@@ -0,0 +1,29 @@
from flask import Flask, request, jsonify, render_template
app = Flask(__name__)
pending_command = None
@app.route('/')
def index():
return render_template('index.html') # Lädt templates/index.html
@app.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
@app.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})
if __name__ == '__main__':
app.run(host='127.0.0.1', port=3060)