From 62bc23271931ca55197f1ee29afcf2cfbebae58c Mon Sep 17 00:00:00 2001 From: sidya82 Date: Thu, 27 Feb 2014 21:22:02 +0100 Subject: [PATCH] =?UTF-8?q?=09modifi=C3=A9:=20=20=20=20=20=20=20=20=20supe?= =?UTF-8?q?rTornado.py=20=09nouveau=20fichier:=20test.html?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- superTornado.py | 22 +++++++++++++++++++++- test.html | 30 ++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 test.html diff --git a/superTornado.py b/superTornado.py index 139daf1..6090b61 100644 --- a/superTornado.py +++ b/superTornado.py @@ -1,6 +1,10 @@ import tornado.ioloop import tornado.web import tornado.httpserver +import tornado.websocket +from tornado.ioloop import PeriodicCallback + + from loadConf import * from login import * @@ -41,12 +45,27 @@ class MainHandler(tornado.web.RequestHandler): class VideoHandler(tornado.web.RequestHandler): def get(self): - self.write("Authorized user access") + self.render("test.html") + +class WSHandler(tornado.websocket.WebSocketHandler): + def open(self): + self.callback = PeriodicCallback(self.send_hello, 120) + self.callback.start() + + def send_hello(self): + self.write_message('hello') + + def on_message(self, message): + pass + + def on_close(self): + self.callback.stop() application = tornado.web.Application([ (r"/", MainHandler), (r"/video", VideoHandler), + (r"/test", WSHandler), ]) if __name__ == "__main__": @@ -60,3 +79,4 @@ if __name__ == "__main__": http_server = tornado.httpserver.HTTPServer(application) http_server.listen(80) tornado.ioloop.IOLoop.instance().start() + diff --git a/test.html b/test.html new file mode 100644 index 0000000..8163bf5 --- /dev/null +++ b/test.html @@ -0,0 +1,30 @@ + + + + + + + + + +