esp_routes_basic and server comm
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
from flask import Blueprint, render_template, request, jsonify
|
||||
|
||||
import routes.shared as shared
|
||||
unsecure = Blueprint('unsecure', __name__, url_prefix='/unsecure')
|
||||
|
||||
pending_command = None
|
||||
|
||||
|
||||
@unsecure.route('/')
|
||||
def index():
|
||||
@@ -10,21 +10,16 @@ def index():
|
||||
|
||||
@unsecure.route('/send')
|
||||
def send_command():
|
||||
global pending_command
|
||||
pCd = shared.pending_command
|
||||
befehl = request.args.get('befehl')
|
||||
if befehl:
|
||||
pending_command = befehl
|
||||
return f"Befehl '{befehl}' gespeichert."
|
||||
pCd['command'] = befehl
|
||||
pCd['command-URL'] = '/unsecure/esp/someURI'
|
||||
pCd.update({'extra': 'test'})
|
||||
print(pCd)
|
||||
return f"Befehl '{pCd}' 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})
|
||||
@unsecure.route('/test')
|
||||
def test():
|
||||
return render_template('test.html')
|
||||
|
||||
Reference in New Issue
Block a user