modifié: superTornado.py
This commit is contained in:
parent
c7cce89284
commit
bbd59adfde
@ -27,6 +27,7 @@ class BaseHandler(tornado.web.RequestHandler):
|
|||||||
class MainHandler(BaseHandler):
|
class MainHandler(BaseHandler):
|
||||||
def get(self):
|
def get(self):
|
||||||
self.render("v/index.html")
|
self.render("v/index.html")
|
||||||
|
|
||||||
def post(self):
|
def post(self):
|
||||||
iden = self.get_argument("id","")
|
iden = self.get_argument("id","")
|
||||||
mdp = self.get_argument("mdp","")
|
mdp = self.get_argument("mdp","")
|
||||||
@ -51,6 +52,7 @@ class VideoHandler(BaseHandler):
|
|||||||
class UnauthorizedHandler(BaseHandler):
|
class UnauthorizedHandler(BaseHandler):
|
||||||
def get(self):
|
def get(self):
|
||||||
self.render("v/illegal.html")
|
self.render("v/illegal.html")
|
||||||
|
|
||||||
def post(self):
|
def post(self):
|
||||||
force = self.get_argument("illegalAccess","")
|
force = self.get_argument("illegalAccess","")
|
||||||
if force == "1" :
|
if force == "1" :
|
||||||
@ -93,29 +95,11 @@ class WSocketHandler(BaseHandler,tornado.websocket.WebSocketHandler):
|
|||||||
print '->Send visual alarm authorized user'
|
print '->Send visual alarm authorized user'
|
||||||
print 'maison.request("GET", "micom/lamp.php?room=salon1&order=1")'
|
print 'maison.request("GET", "micom/lamp.php?room=salon1&order=1")'
|
||||||
print "->Authorized user access"
|
print "->Authorized user access"
|
||||||
|
self.send_image()
|
||||||
try :
|
|
||||||
socket.setdefaulttimeout(5)
|
|
||||||
f = urlopen('http://test:a@192.168.0.13/image.jpg?cidx=791836195')
|
|
||||||
data = f.read()
|
|
||||||
encoded = base64.b64encode(data)
|
|
||||||
self.write_message(encoded)
|
|
||||||
except Exception, e :
|
|
||||||
print e
|
|
||||||
self.write_message("error")
|
|
||||||
|
|
||||||
|
|
||||||
def on_message(self,mesg):
|
def on_message(self,mesg):
|
||||||
print "->Data receive"
|
print "->Data receive"
|
||||||
try :
|
self.send_image()
|
||||||
socket.setdefaulttimeout(5)
|
|
||||||
f = urlopen('http://test:a@192.168.0.13/image.jpg?cidx=791836195')
|
|
||||||
data = f.read()
|
|
||||||
encoded = base64.b64encode(data)
|
|
||||||
self.write_message(encoded)
|
|
||||||
except Exception, e :
|
|
||||||
print e
|
|
||||||
self.write_message("error")
|
|
||||||
|
|
||||||
def on_close(self):
|
def on_close(self):
|
||||||
print "->Websocket closed"
|
print "->Websocket closed"
|
||||||
@ -126,7 +110,6 @@ class WSocketHandler(BaseHandler,tornado.websocket.WebSocketHandler):
|
|||||||
iden = self.current_user
|
iden = self.current_user
|
||||||
ficLog.enregDansLog(iden,"Authorized user deconnection","IP TO DO")
|
ficLog.enregDansLog(iden,"Authorized user deconnection","IP TO DO")
|
||||||
|
|
||||||
|
|
||||||
if confAveug == True:
|
if confAveug == True:
|
||||||
print '->Send audio alarm deconnection user'
|
print '->Send audio alarm deconnection user'
|
||||||
print 'maison.request("GET", "micom/say.php?source=toto&text=Connection%20a%20la%20camera%20rompue")'
|
print 'maison.request("GET", "micom/say.php?source=toto&text=Connection%20a%20la%20camera%20rompue")'
|
||||||
@ -135,6 +118,18 @@ class WSocketHandler(BaseHandler,tornado.websocket.WebSocketHandler):
|
|||||||
print 'maison.request("GET", "micom/lamp.php?room=salon1&order=0")'
|
print 'maison.request("GET", "micom/lamp.php?room=salon1&order=0")'
|
||||||
print"->"+iden+" Deconnection"
|
print"->"+iden+" Deconnection"
|
||||||
|
|
||||||
|
def send_image(self) :
|
||||||
|
try :
|
||||||
|
socket.setdefaulttimeout(5)
|
||||||
|
f = urlopen('http://test:a@192.168.0.13/image.jpg?cidx=791836195')
|
||||||
|
data = f.read()
|
||||||
|
encoded = base64.b64encode(data)
|
||||||
|
self.write_message(encoded)
|
||||||
|
print ("->Data send")
|
||||||
|
except Exception, e :
|
||||||
|
print e
|
||||||
|
self.write_message("error")
|
||||||
|
|
||||||
application = tornado.web.Application([
|
application = tornado.web.Application([
|
||||||
(r"/", MainHandler),
|
(r"/", MainHandler),
|
||||||
(r"/video", VideoHandler),
|
(r"/video", VideoHandler),
|
||||||
@ -158,4 +153,3 @@ if __name__ == "__main__":
|
|||||||
http_server = tornado.httpserver.HTTPServer(application)
|
http_server = tornado.httpserver.HTTPServer(application)
|
||||||
http_server.listen(80)
|
http_server.listen(80)
|
||||||
tornado.ioloop.IOLoop.instance().start()
|
tornado.ioloop.IOLoop.instance().start()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user