add client overview
parent
09f83003a0
commit
bd54f3d3dc
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Aktive Rechner</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Aktive Rechner:
|
||||
<table>
|
||||
<tr>
|
||||
<th>Rechner</th>
|
||||
</tr>
|
||||
%for item in clientdata:
|
||||
<tr>
|
||||
<td><a href="/client/{{item}}">{{item}}</a></td>
|
||||
</tr>
|
||||
%end
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
35
pyweb.py
35
pyweb.py
|
@ -238,6 +238,41 @@ def show_temperature():
|
|||
zs=int(tims)
|
||||
return template('temperature.tpl',tempdata=thp,zeitstempel=time.strftime('%H:%M:%S %Y-%m-%d', time.localtime(zs/1000)))
|
||||
|
||||
@app.get('/clients')
|
||||
def show_clients():
|
||||
mydb=pymysql.connect(read_default_file="~/.my.cnf",database="rasolar")
|
||||
myc=mydb.cursor(pymysql.cursors.DictCursor)
|
||||
no_clients=myc.execute('select distinct ids.device from ids join hourly_measures on hourly_measures.id=ids.id;')
|
||||
if no_clients > 0:
|
||||
t_cl=myc.fetchall()
|
||||
client_list={}
|
||||
for cl in t_cl:
|
||||
client_list.append(cl)
|
||||
return template(clients.tpl,td=str(int(1000*time.time())))
|
||||
else:
|
||||
return '''
|
||||
<!DOCTYPE html><html><head>
|
||||
<title>Übersicht Tristar</title>
|
||||
</head><body>
|
||||
<p>Aktuell keine Rechner verbunden</p>
|
||||
</body></html>
|
||||
'''
|
||||
@app.get('/client/<client>')
|
||||
def forward_client(client):
|
||||
response=request.get('http://'+client+':8080/')
|
||||
if response.status_code == 200:
|
||||
return response.content
|
||||
else:
|
||||
return '''
|
||||
<!DOCTYPE html><html><head>
|
||||
<title>Keine Verbindung</title>
|
||||
</head><body>
|
||||
<p>Kein Anschluss unter dieser Himbeere</p>
|
||||
</body></html>
|
||||
'''
|
||||
|
||||
|
||||
|
||||
@app.get('/cpu')
|
||||
def show_ids():
|
||||
starttime=time.time()
|
||||
|
|
Loading…
Reference in New Issue