From 7c9ba01568fd984ec3eb4de0767be0a67f76ae82 Mon Sep 17 00:00:00 2001 From: sidya82 Date: Sun, 2 Mar 2014 21:48:37 +0100 Subject: [PATCH] =?UTF-8?q?=09modifi=C3=A9:=20=20=20=20=20=20=20=20=20supe?= =?UTF-8?q?rTornado.py=20=09modifi=C3=A9:=20=20=20=20=20=20=20=20=20v/vide?= =?UTF-8?q?o.html?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- superTornado.py | 51 +++++++++++++++++++++++++------------------------ v/video.html | 2 +- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/superTornado.py b/superTornado.py index 0ba4836..98bf820 100644 --- a/superTornado.py +++ b/superTornado.py @@ -26,6 +26,7 @@ class BaseHandler(tornado.web.RequestHandler): class MainHandler(BaseHandler): def get(self): + print "-> IP = " + self.remote_ip self.render("v/index.html") def post(self): @@ -42,13 +43,35 @@ class MainHandler(BaseHandler): print "->An unauthorized user try to access" self.redirect("/unauthorized") -class VideoHandler(BaseHandler,tornado.websocket.WebSocketHandler): +class VideoHandler(BaseHandler): def get(self): if not self.current_user : self.redirect("/") return self.render("v/video.html") +class UnauthorizedHandler(BaseHandler): + def get(self): + self.render("v/illegal.html") + + def post(self): + force = self.get_argument("illegalAccess","") + if force == "1" : + self.set_secure_cookie("user", "illegalUser") + self.redirect("/video") + else : + self.redirect("/") + + +class DisconnectionHandler(BaseHandler): + def post(self): + if not self.current_user : + self.close() + return + self.clear_cookie("user") + self.redirect("/") + +class WSocketHandler(BaseHandler,tornado.websocket.WebSocketHandler): def open(self) : if not self.current_user : self.close() @@ -96,6 +119,7 @@ class VideoHandler(BaseHandler,tornado.websocket.WebSocketHandler): print 'maison.request("GET", "micom/lamp.php?room=salon1&order=0")' print"->"+iden+" Deconnection" + def send_image(self) : try : socket.setdefaulttimeout(5) @@ -108,35 +132,12 @@ class VideoHandler(BaseHandler,tornado.websocket.WebSocketHandler): print e self.write_message("error") - -class UnauthorizedHandler(BaseHandler): - def get(self): - self.render("v/illegal.html") - - def post(self): - force = self.get_argument("illegalAccess","") - if force == "1" : - self.set_secure_cookie("user", "illegalUser") - self.redirect("/video") - else : - self.redirect("/") - - -class DisconnectionHandler(BaseHandler): - def post(self): - if not self.current_user : - self.close() - return - self.clear_cookie("user") - self.redirect("/") - - - application = tornado.web.Application([ (r"/", MainHandler), (r"/video", VideoHandler), (r"/unauthorized", UnauthorizedHandler), (r"/disconnection", DisconnectionHandler), + (r"/socket", WSocketHandler), (r"/style/(.*)", tornado.web.StaticFileHandler,{"path":"./v/style"},), (r"/images/(.*)", tornado.web.StaticFileHandler,{"path":"./v/images"},), (r"/js/(.*)", tornado.web.StaticFileHandler,{"path":"./v/js"},)], diff --git a/v/video.html b/v/video.html index 815b91b..f39cdc2 100644 --- a/v/video.html +++ b/v/video.html @@ -6,7 +6,7 @@ Acces camera