new subpage for daily diagram
parent
2ee6944fb4
commit
8eb16c1454
35
pyweb.py
35
pyweb.py
|
@ -312,19 +312,28 @@ def show_graph(mid,kind):
|
||||||
mydb=pymysql.connect(read_default_file="~/.my.cnf",database="rasolar")
|
mydb=pymysql.connect(read_default_file="~/.my.cnf",database="rasolar")
|
||||||
mycursor=mydb.cursor()
|
mycursor=mydb.cursor()
|
||||||
print(str(time.time()-starttime)+' sql open')
|
print(str(time.time()-starttime)+' sql open')
|
||||||
mycursor.execute('select ((select max(time) from '+sqltable+')-'+sqltable+'.time)/6400000 as time,'+sqltable+'.value/1000 as value from '+sqltable+' where id=%s order by time',str(mid))
|
nrow=mycursor.execute('select ((select max(time) from '+sqltable+')-'+sqltable+'.time)/6400000 as time,'+sqltable+'.value/1000 as value from '+sqltable+' where id=%s order by time',str(mid))
|
||||||
row=numpy.array(mycursor.fetchall())
|
if (nrow>0):
|
||||||
print(str(time.time()-starttime)+' sql fetched')
|
row=numpy.array(mycursor.fetchall())
|
||||||
mycursor.close()
|
print(str(time.time()-starttime)+' sql fetched')
|
||||||
mydb.close()
|
mycursor.close()
|
||||||
print(str(time.time()-starttime)+' sql closed')
|
mydb.close()
|
||||||
plt.figure(figsize=[6,8])
|
print(str(time.time()-starttime)+' sql closed')
|
||||||
plt.plot(row[:,0],row[:,1])
|
plt.figure(figsize=[6,8])
|
||||||
print(str(time.time()-starttime)+' picture')
|
plt.plot(row[:,0],row[:,1])
|
||||||
plt.savefig("svg/"+mid+".svg")
|
print(str(time.time()-starttime)+' picture')
|
||||||
print(str(time.time()-starttime)+' saved')
|
plt.savefig("svg/"+mid+".svg")
|
||||||
if len(row)>0:
|
print(str(time.time()-starttime)+' saved')
|
||||||
return template('verlauf.tpl',measdata=row,mid=mid)
|
if len(row)>0:
|
||||||
|
return template('verlauf.tpl',measdata=row,mid=mid)
|
||||||
|
else:
|
||||||
|
return '''
|
||||||
|
<!DOCTYPE html><html><head>
|
||||||
|
<title>Keine Daten</title>
|
||||||
|
</head><body>
|
||||||
|
<p>Die Daten verstecken sich.</p>
|
||||||
|
</body></html>
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
@app.post('/data/<hash_id>')
|
@app.post('/data/<hash_id>')
|
||||||
|
|
Loading…
Reference in New Issue