heartbeatserver/heartbeat/frontend.py

26 lines
685 B
Python
Raw Normal View History

2018-10-23 22:07:28 +02:00
# TODO: web frontend
import os
import tornado.web
import tornado.template
viewdir = os.path.dirname(os.path.realpath(__file__)) + '/../views'
loader = tornado.template.Loader(viewdir)
class FrontendHandler(tornado.web.RequestHandler):
def initialize(self, conn):
"""
conn: sqlite3 connection
"""
self.conn = conn
def get(self):
# c = self.conn.cursor()
# c.execute("SELECT * FROM beats ORDER BY createdAt DESC LIMIT 20")
# beats = [row for row in c]
# print(beats)
# html = loader.load("sockets.html").generate(beats=beats)
html = loader.load("plot.html").generate()
self.write(html)