moved images to appropriate folder
added image hash
This commit is contained in:
parent
70c4de1a30
commit
4e2311df7d
7 changed files with 39 additions and 3 deletions
|
@ -11,6 +11,7 @@ from datetime import datetime
|
|||
from flask import Flask, render_template
|
||||
import json
|
||||
import matplotlib
|
||||
import hashlib
|
||||
matplotlib.use('Agg')
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
|
@ -45,6 +46,7 @@ class Sensor:
|
|||
self.values: list = value
|
||||
self.timeonly: list = []
|
||||
self.timedate: list = []
|
||||
self.hash = hashlib.sha256(repr(ts).encode()).hexdigest()
|
||||
for i in ts:
|
||||
# print(i)
|
||||
self.timeonly.append(datetime.fromtimestamp(int(i)).strftime("%H:%M.%S"))
|
||||
|
@ -108,6 +110,9 @@ class Sensor:
|
|||
plt.close()
|
||||
return path
|
||||
|
||||
def getHash(self):
|
||||
return self.hash
|
||||
|
||||
|
||||
readJson()
|
||||
|
||||
|
@ -122,6 +127,10 @@ app = Flask(__name__)
|
|||
def index():
|
||||
return render_template("index.html", data=sensors)
|
||||
|
||||
@app.before_request
|
||||
def reload_data():
|
||||
readJson()
|
||||
print("hello")
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(debug=True)
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
font-size: 18px;
|
||||
color: white;
|
||||
background: #1c1c1c;
|
||||
<!-- margin: 0; -->
|
||||
<!-- padding: 0; -->
|
||||
<!-- box-sizing: border-box; -->
|
||||
}
|
||||
.container {
|
||||
display: flex; /* Enable flexbox */
|
||||
|
@ -41,18 +44,26 @@
|
|||
background-color: #C4FA05; /* Background color for the boxes */
|
||||
justify-content: left; /* Center text horizontally */
|
||||
}
|
||||
.txtbox h1 {
|
||||
margin: 0;
|
||||
padding: 0.5em 0; /* optional: add some vertical padding */
|
||||
}
|
||||
.txtbox h2 {
|
||||
margin: 0;
|
||||
padding: 0em 0; /* optional: add some vertical padding */
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class = "container">
|
||||
<div class = "txtbox">
|
||||
<div class = "txtbox" style="text-align: center; margin: auto;">
|
||||
<h1>Sensor Readings</h1>
|
||||
</div>
|
||||
</div>
|
||||
<h2>{% for sensor in data.items() %}</h2>
|
||||
<hr>
|
||||
<h2>{{ sensor[1].getId() }}[{{ sensor[1].getType() }}]</h2>
|
||||
<h3>{{ sensor[1].renderPlot() }}</h3>
|
||||
<div class = "container">
|
||||
<div class = "txtbox">
|
||||
<ul>
|
||||
|
@ -63,11 +74,12 @@
|
|||
</div>
|
||||
<div class = "imgbox">
|
||||
<img
|
||||
src="{{ url_for('static', filename='plots/' + sensor[1].getId() + '.png') }}"
|
||||
src="{{ url_for('static', filename= sensor[1].renderPlot()) }}"
|
||||
alt="Graph"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<sub style="text-align: right; float: right;"> {{ sensor[1].getHash() }} </sub>
|
||||
{% endfor %}
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue