modifié: superTornado.py
modifié: video.html
This commit is contained in:
parent
da09c4b8ff
commit
3132c13c35
@ -5,6 +5,7 @@ import tornado.websocket
|
||||
import tornado.options
|
||||
import time
|
||||
import base64
|
||||
import socket
|
||||
from urllib import urlopen
|
||||
|
||||
|
||||
@ -94,16 +95,17 @@ class WSocketHandler(BaseHandler,tornado.websocket.WebSocketHandler):
|
||||
print 'maison.request("GET", "micom/lamp.php?room=salon1&order=1")'
|
||||
print "->Authorized user access"
|
||||
|
||||
""""try :
|
||||
def on_message(self,mesg):
|
||||
print "->Data receive"
|
||||
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"""
|
||||
|
||||
def on_message(self,mesg):
|
||||
print "->Data receive"
|
||||
print e
|
||||
self.write_message("error")
|
||||
|
||||
def on_close(self):
|
||||
print "->Websocket closed"
|
||||
|
10
video.html
10
video.html
@ -12,9 +12,13 @@ return d||(f=$b[b],$b[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,$b[b]=f),e}});v
|
||||
|
||||
var ws = new WebSocket ("ws://192.168.1.23/socket");
|
||||
ws.onmessage = function (evt) {
|
||||
console.log("data receive");
|
||||
var str = "<img src='data:image/jpeg;base64,"+evt.data+"'>";
|
||||
$('.image').html(str);
|
||||
if(evt.data != "error") {
|
||||
console.log("data receive");
|
||||
var str = "<img src='data:image/jpeg;base64,"+evt.data+"'>";
|
||||
$('.image').html(str);
|
||||
}
|
||||
else
|
||||
var str = "<error>Erreur : image camera indisponilbe</error>";
|
||||
}
|
||||
ws.onopen = function () {
|
||||
console.log("websocket engage");
|
||||
|
Reference in New Issue
Block a user