Skip to content

Instantly share code, notes, and snippets.

@joewashear007
joewashear007 / temp-server.py
Created January 6, 2014 01:06
A Simple Web Socket Demo that displays current temperature from a Raspberry pi's GPIO pins using a temperature sensor. Needs: Rashberry Pi, temperature probe, python 2.7, Tornado Webserver 1) Read This: http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/temperature/ 2) Install tornado Webserver 3) Change the ws address in html file to the lo…
import time
import tornado.httpserver
import tornado.websocket
import tornado.ioloop
from tornado.ioloop import PeriodicCallback
import tornado.web
class WSHandler(tornado.websocket.WebSocketHandler):
def open(self):
self.callback = PeriodicCallback(self.send_temp, 120)