add web template

master
ademant 2019-07-31 14:48:24 +02:00
parent 4aee62f1e3
commit 21088b390f
3 changed files with 23 additions and 9 deletions

View File

@ -19,9 +19,9 @@ for n in parameter:
cpu_meas=meas_data(var_name="temperature",ring_length=parameter['ring_length'],device=parameter['device'],sensor="CPU",store_file="/home/pi/log/data_cpu",digits=4,check_last=parameter['check_last']) cpu_meas=meas_data(var_name="temperature",ring_length=parameter['ring_length'],device=parameter['device'],sensor="CPU",store_file="/home/pi/log/data_cpu",digits=4,check_last=parameter['check_last'])
#cpu_meas.set_sql(host="localhost",port=24048,min_wait=60) cpu_meas.set_sql(host="localhost",port=24048,min_wait=60)
#cpu_meas.set_rsa('key.der') cpu_meas.set_rsa('@radew')
#requests.post("http://localhost:8080/data/"+str(cpu_meas.json_out['hash']),json=cpu_meas.json_out) requests.post("http://localhost:8080/data/"+str(cpu_meas.json_out['hash']),json=cpu_meas.json_out)
if "sqlserver" in log_conf: if "sqlserver" in log_conf:
hostname="banana" hostname="banana"

16
main.tpl Normal file
View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>Übersicht {{server}}</title>
</head>
<body>
<p>Auslastung: {{cpupercent}}</p>
<p>Aktuelle Variablen:
<ul>
%for item in measdata:
%measlen=len(measdata[item]['measures'])
<li>{{measdata[item]['varname']}}: {{measlen}}</li>
%end
</ul>
</body>
</html>

View File

@ -1,5 +1,5 @@
from bottle import get,post,request,Bottle,run from bottle import get,post,request,Bottle,run,template
import threading,time,json,zlib,gnupg import threading,time,json,zlib,gnupg,socket,psutil
from queue import Queue from queue import Queue
@ -17,6 +17,7 @@ def sql_insert(q):
while True: while True:
if q.empty(): if q.empty():
time.sleep(0.1) time.sleep(0.1)
print("ping"+str(time.time()))
else: else:
try: try:
indata=q.get() indata=q.get()
@ -40,10 +41,7 @@ app=Bottle()
@app.get('/') @app.get('/')
def approot(): def approot():
return ''' return template('main.tpl',server=socket.gethostname(),cpupercent=psutil.cpu_percent(),measdata=measdata)
<a href="/haus">Dateneingabe Haus</a></br>
<a href="/kfz">Dateneingabe KFZ</a></br>
'''
@app.post('/data/<hash_id:int>') @app.post('/data/<hash_id:int>')
def dataimport(hash_id): def dataimport(hash_id):