from flask import Flask, render_template, request, redirect, url_for app = Flask(__name__) # Dictionary to store commands for multiple devices or functionalities commands = { "LED": "Off", # Default LED state "Servo": "90", # Default Servo position } @app.route("/") def index(): return render_template("index.html", commands=commands) @app.route("/set_command", methods=["POST"]) def set_command(): # Get the device and command from the form device = request.form.get("device") command = request.form.get("command") if device in commands: commands[device] = command return redirect(url_for("index")) if __name__ == "__main__": app.run()