diff --git a/.gitignore b/.gitignore index 894a44c..70391ce 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,4 @@ venv.bak/ # mypy .mypy_cache/ +.idea/ \ No newline at end of file diff --git a/Hanna/arduino/main.py b/Hanna/arduino/main.py new file mode 100644 index 0000000..00b3778 --- /dev/null +++ b/Hanna/arduino/main.py @@ -0,0 +1,43 @@ +import serial +from flask import Flask, render_template, redirect, request + + +def send(cmd): + ser = serial.Serial() + ser.rts = False + ser.dtr = False + ser.port = "COM3" + ser.open() + ser.write(cmd) + ser.close() + + +app = Flask(__name__) + + +@app.route('/') +def hello_world(): + return render_template("index.html") + + +@app.route('/red') +def red(): + send(b"r") + return redirect('/') + + +@app.route('/blue') +def blue(): + send(b"t") + return redirect('/') + + +@app.route('/led', methods=["POST"]) +def led(): + cmd = request.form["cmd"] + send(cmd.encode()) + return redirect("/") + + +if __name__ == '__main__': + app.run(host="0.0.0.0") diff --git a/Hanna/arduino/templates/index.html b/Hanna/arduino/templates/index.html new file mode 100644 index 0000000..47fc3bc --- /dev/null +++ b/Hanna/arduino/templates/index.html @@ -0,0 +1,21 @@ + + +
+ +