From 58e4666d96b49219b45eff7f8e0b03bf10c5c7f4 Mon Sep 17 00:00:00 2001 From: Jared Dunbar Date: Sun, 12 Mar 2023 00:35:05 -0500 Subject: [PATCH] Initial Commit --- main.py | 39 +++++++++++++++++++++++++++++++++++++++ templates/index.html | 27 +++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 main.py create mode 100644 templates/index.html diff --git a/main.py b/main.py new file mode 100644 index 0000000..52fe49b --- /dev/null +++ b/main.py @@ -0,0 +1,39 @@ +from flask import request, Flask, render_template + +app = Flask(__name__) +app.debug=True +app.config['SECRET_KEY'] = 'Thisisasecret!' + +throttle: float = 0.0 +direction: int = 0 + +@app.route('/') +def index(): + return render_template('index.html') + +@app.route("/data", methods=["POST"]) +def data(): + global throttle, direction + print(request.json) + + if "throttle" in request.json: + throttle = int(request.json["throttle"]) / 100.0 + print(throttle) + if "direction" in request.json: + direction = int(request.json["direction"]) + print(direction) + + return "Success" + +@app.route("/control", methods=["GET"]) +def control(): + print(request.data) + + return { + "throttle": throttle, + "direction": direction + } + + +if __name__=="__main__": + app.run(host="10.0.2.148", port=2093) \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..5816eb2 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,27 @@ + + + +
+ + +
+ + + \ No newline at end of file