From 21088b390f7e4ac42c25b8de1b54318a1df34674 Mon Sep 17 00:00:00 2001 From: ademant Date: Wed, 31 Jul 2019 14:48:24 +0200 Subject: [PATCH] add web template --- log_cpu.py | 6 +++--- main.tpl | 16 ++++++++++++++++ pyweb.py | 10 ++++------ 3 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 main.tpl diff --git a/log_cpu.py b/log_cpu.py index 778dda2..50af821 100644 --- a/log_cpu.py +++ b/log_cpu.py @@ -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.set_sql(host="localhost",port=24048,min_wait=60) -#cpu_meas.set_rsa('key.der') -#requests.post("http://localhost:8080/data/"+str(cpu_meas.json_out['hash']),json=cpu_meas.json_out) +cpu_meas.set_sql(host="localhost",port=24048,min_wait=60) +cpu_meas.set_rsa('@radew') +requests.post("http://localhost:8080/data/"+str(cpu_meas.json_out['hash']),json=cpu_meas.json_out) if "sqlserver" in log_conf: hostname="banana" diff --git a/main.tpl b/main.tpl new file mode 100644 index 0000000..8a0323a --- /dev/null +++ b/main.tpl @@ -0,0 +1,16 @@ + + + +Übersicht {{server}} + + +

Auslastung: {{cpupercent}}

+

Aktuelle Variablen: +

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