diff --git a/app.py b/app.py index 8c216e7..9a4140f 100644 --- a/app.py +++ b/app.py @@ -1,6 +1,6 @@ # app.py -from flask import Flask, render_template, request +from flask import Flask, render_template, request, jsonify from flask_assets import Bundle, Environment import random app = Flask(__name__) @@ -16,6 +16,19 @@ css.build() def homepage(): return render_template("index.html") +@app.route('/api/datapoint') +def api_datapoint(): + + deg = [int(random.random() * 100) / 100 for _ in range(3)] + dictionary_to_return = { + 'angle1': deg[0], + 'angle2': deg[1], + 'angle3': deg[2] + } + + return jsonify(dictionary_to_return) + + @app.route("/sendData", methods =["GET", "POST"]) def sendData(): @@ -39,10 +52,7 @@ def sendData(): return render_template("index.html", conf='Invalid Input "'+rot+'"') except: return render_template("index.html", conf='Timeout: Unable to reach Pi') -@app.context_processor -def inject_load1(): - deg = [int(random.random() * 100) / 100 for _ in range(3)] - return {'load1': deg[0], 'load2': deg[1], 'load3' :deg[2]} + if __name__ == "__main__": app.run(debug=True) diff --git a/templates/base.html b/templates/base.html index 9c8866e..d655e6c 100644 --- a/templates/base.html +++ b/templates/base.html @@ -8,10 +8,16 @@ {% assets 'css' %} {% endassets %} + Potentia Robotics GUI - +

{{ conf }}

@@ -154,5 +160,32 @@
+ + diff --git a/templates/drop1.html b/templates/drop1.html index 69ece47..d402fd7 100644 --- a/templates/drop1.html +++ b/templates/drop1.html @@ -3,7 +3,7 @@ src="{{url_for('static', filename='images/img-knee.png')}}" class="img-part" /> -

{{ load1 }}

+

NaN

diff --git a/templates/drop2.html b/templates/drop2.html index a04cf80..bf2f9f3 100644 --- a/templates/drop2.html +++ b/templates/drop2.html @@ -3,7 +3,7 @@ src="{{url_for('static', filename='images/img-knee.png')}}" class="img-part" /> -

{{ load2 }}

+

NaN

diff --git a/templates/drop3.html b/templates/drop3.html index 7b6ebcb..eba5695 100644 --- a/templates/drop3.html +++ b/templates/drop3.html @@ -3,7 +3,7 @@ src="{{url_for('static', filename='images/img-knee.png')}}" class="img-part" /> -

{{ load3 }}

+

NaN