From 73f8b3f0d38d6a411f5c843a88502bbac29de445 Mon Sep 17 00:00:00 2001 From: FluffyCube9343 Date: Mon, 14 Nov 2022 11:41:16 -0500 Subject: [PATCH] stable random modify data --- app.py | 7 +++++-- templates/base.html | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index 633516c..daa19a7 100644 --- a/app.py +++ b/app.py @@ -2,7 +2,7 @@ from flask import Flask, render_template, request from flask_assets import Bundle, Environment - +import random app = Flask(__name__) assets = Environment(app) @@ -39,7 +39,10 @@ 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 03dcb13..8ba15e3 100644 --- a/templates/base.html +++ b/templates/base.html @@ -27,7 +27,7 @@ src="{{url_for('static', filename='images/img-knee.png')}}" class="img-part" /> -

360

+

{{ load1 }}

-

360

+

{{ load2 }}

-

360

+

{{ load3 }}