I am trying to use Tornado to display data from a serial port on a web page using this:
from tornado import ioloop, web
from serial import Serial
class MainHandler(web.RequestHandler):
def get(self):
serialInterface = Serial("/dev/ttyUSB0",19200)
self.render("template.html", serialData = serialInterface.readline())
serialInterface.close()
application = web.Application([
(r"/", MainHandler),
])
if __name__ == "__main__":
application.listen(8000)
ioloop.IOLoop.instance().start()
While this works, I need a way to continuously refresh the page every second to show the latest data received from the serial port. How do I go about doing this?
Much obliged!