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")
|
||||
mycursor=mydb.cursor()
|
||||
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))
|
||||
row=numpy.array(mycursor.fetchall())
|
||||
print(str(time.time()-starttime)+' sql fetched')
|
||||
mycursor.close()
|
||||
mydb.close()
|
||||
print(str(time.time()-starttime)+' sql closed')
|
||||
plt.figure(figsize=[6,8])
|
||||
plt.plot(row[:,0],row[:,1])
|
||||
print(str(time.time()-starttime)+' picture')
|
||||
plt.savefig("svg/"+mid+".svg")
|
||||
print(str(time.time()-starttime)+' saved')
|
||||
if len(row)>0:
|
||||
return template('verlauf.tpl',measdata=row,mid=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))
|
||||
if (nrow>0):
|
||||
row=numpy.array(mycursor.fetchall())
|
||||
print(str(time.time()-starttime)+' sql fetched')
|
||||
mycursor.close()
|
||||
mydb.close()
|
||||
print(str(time.time()-starttime)+' sql closed')
|
||||
plt.figure(figsize=[6,8])
|
||||
plt.plot(row[:,0],row[:,1])
|
||||
print(str(time.time()-starttime)+' picture')
|
||||
plt.savefig("svg/"+mid+".svg")
|
||||
print(str(time.time()-starttime)+' saved')
|
||||
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>')
|
||||
|
|
Loading…
Reference in New Issue