commit 58e4666d96b49219b45eff7f8e0b03bf10c5c7f4 Author: Jared Dunbar Date: Sun Mar 12 00:35:05 2023 -0500 Initial Commit 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