-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonitor_web.py
49 lines (36 loc) · 881 Bytes
/
monitor_web.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#coding:utf-8
'''
Created on 2017年4月11日
@author: superxiaoxiong
'''
import web
import json
urls = (
'/(.*)/','redirect',
'/data', 'data',
'/index','index',
)
class redirect:
def GET(self, path):
web.seeother('/'+ path)
'''
def notfound():
return web.seeother('./index')
'''
app = web.application(urls, globals())
#app.notfound = notfound
db1 = web.database(dbn = 'mysql', db='webuser', user='root',pw='root')
class index:
def GET(self):
render = web.template.render('templates')
return "%s" % (render.index())
class data:
def GET(self):
sql = 'select memory,time from monitor '
results = db1.query(sql )
arr = []
for item in results:
arr.append([int(item.time)*1000,item.memory])
return json.dumps(arr)
if __name__ == "__main__":
app.run()