def do_log():
		with open ("covidgrapher_flask.log") as log:
			l = log.read()
		logstring = "<h1>Covid Grapher Log</h1>"
		for l in reversed(l.splitlines()):
			logstring += f"<p class='logline'>{l}</p>"
		return build_page("Covid Grapher Log", logstring, STYLE)
Exemplo n.º 2
0
        async def read_log(request):
            with open("bot.log") as log:
                l = log.read()
            logstring = "<h1>Covid Grapher Bot Log</h1>"
            for l in reversed(l.splitlines()):
                logstring += f"<p class='logline'>{l}</p>"

            page = build_page("Covid Grapher Bot Log", logstring, STYLE)
            return web.Response(text=page, content_type='text/html')
	def apply(*args, **kw):
		try:
			t = time.ctime()
			name = method.__name__
			outstr = f"Method '{name}' at {t}"
			print(outstr)
			start = time.time()
			print(args, kw)
			result = method(*args, **kw)
			end = time.time()
			outstr = 'Method - {} took {} ms'.format(method.__name__, "%2.2f" % ((end - start) * 1000))
			print(outstr)
			return result
		except Exception as e:
			title = f"Error running {method.__name__} with args {args} and kwargs {kw}"
			string = traceback.format_exc()
			print(title, string)
			return build_page("Error loading page", getHTMLErrorString(title, string.replace("\n", "<br/>")), STYLE)
Exemplo n.º 4
0
 async def get_form(request):
     page = build_page("Covid Grapher API Web Form", COVIDFORM, STYLE,
                       COVIDFORMSCRIPT)
     return web.Response(text=page, content_type='text/html')
Exemplo n.º 5
0
 async def bot_stats(request):
     bot_stats_text = get_bot_stats_html(bot)
     page = build_page("Bot Statistics", bot_stats_text, STYLE)
     return web.Response(text=page, content_type='text/html')
Exemplo n.º 6
0
 async def welcome(request):
     page = build_page("Covid Grapher Bot Home Page", HOMEPAGE, STYLE)
     return web.Response(text=page, content_type='text/html')
	def do_form():
		return build_page("Covid Grapher API Web Form", COVIDFORM, STYLE, COVIDFORMSCRIPT)
	def do_home():
		return build_page("Covid Grapher Flask Home Page", HOMEPAGE, STYLE)