init py server
This commit is contained in:
29
server.py
Normal file
29
server.py
Normal 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)
|
||||
Reference in New Issue
Block a user