add route to download report file
This commit is contained in:
parent
a1a39f0b1b
commit
3aa7835802
|
@ -66,9 +66,11 @@ def getMonit():
|
||||||
checks[name] = status[name]
|
checks[name] = status[name]
|
||||||
|
|
||||||
sorted_checks = OrderedDict()
|
sorted_checks = OrderedDict()
|
||||||
sorted_checks = OrderedDict(sorted(checks.iteritems(), key=itemgetter(1), reverse=True))
|
sorted_checks = OrderedDict(sorted(checks.iteritems(),
|
||||||
|
key=itemgetter(1), reverse=True))
|
||||||
count = calculate_count(sorted_checks)
|
count = calculate_count(sorted_checks)
|
||||||
server = dict(name=site, url=s['url'], result=sorted_checks, s_rate=count)
|
server = dict(name=site, url=s['url'],
|
||||||
|
result=sorted_checks, s_rate=count)
|
||||||
|
|
||||||
output.append(server)
|
output.append(server)
|
||||||
print(datetime.datetime.now())
|
print(datetime.datetime.now())
|
||||||
|
@ -77,23 +79,31 @@ def getMonit():
|
||||||
# Classes
|
# Classes
|
||||||
|
|
||||||
class monitDashboard(web.application):
|
class monitDashboard(web.application):
|
||||||
|
|
||||||
def run(self, port=8080, *middleware):
|
def run(self, port=8080, *middleware):
|
||||||
func = self.wsgifunc(*middleware)
|
func = self.wsgifunc(*middleware)
|
||||||
return web.httpserver.runsimple(func, ('0.0.0.0', port))
|
return web.httpserver.runsimple(func, ('0.0.0.0', port))
|
||||||
|
|
||||||
|
|
||||||
class index(object):
|
class index(object):
|
||||||
|
|
||||||
def GET(self):
|
def GET(self):
|
||||||
return render.index(output=getMonit(), now=datetime.datetime.now())
|
return render.index(output=getMonit(), now=datetime.datetime.now())
|
||||||
|
|
||||||
|
|
||||||
class help(object):
|
class help(object):
|
||||||
|
|
||||||
def GET(self):
|
def GET(self):
|
||||||
return render.help()
|
return render.help()
|
||||||
|
|
||||||
|
class download(object):
|
||||||
|
def GET(self):
|
||||||
|
filename = 'health_report.xlsx'
|
||||||
|
output = getMonit()
|
||||||
|
utils.generate_report_excel(output, filename)
|
||||||
|
web.header('Content-Disposition',
|
||||||
|
'attachment; filename="health_report.xlsx"')
|
||||||
|
web.header('Content-type','application/octet-stream')
|
||||||
|
web.header('Cache-Control','no-cache')
|
||||||
|
return open(filename, 'rb').read()
|
||||||
|
|
||||||
# Main
|
# Main
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = monitDashboard(urls, globals())
|
app = monitDashboard(urls, globals())
|
||||||
|
|
Loading…
Reference in a new issue