modifié: superTornado.py
modifié: video.html
This commit is contained in:
parent
eb6434e84e
commit
884ab14b45
@ -51,12 +51,8 @@ class VideoHandler(BaseHandler):
|
|||||||
return
|
return
|
||||||
name = tornado.escape.xhtml_escape(self.current_user)
|
name = tornado.escape.xhtml_escape(self.current_user)
|
||||||
urlretrieve('http://test:a@192.168.1.15/image.jpg?cidx=791836195', 'image/temp.jpg')
|
urlretrieve('http://test:a@192.168.1.15/image.jpg?cidx=791836195', 'image/temp.jpg')
|
||||||
self.write("video.html")
|
self.render("video.html")
|
||||||
with open("image/temp.jpg", 'rb') as f:
|
|
||||||
data = f.read()
|
|
||||||
self.set_header('Content-type', 'image/jpg')
|
|
||||||
self.write(data)
|
|
||||||
self.finish()
|
|
||||||
|
|
||||||
class UnauthorizedHandler(BaseHandler):
|
class UnauthorizedHandler(BaseHandler):
|
||||||
def get(self):
|
def get(self):
|
||||||
@ -80,7 +76,11 @@ class UnauthorizedHandler(BaseHandler):
|
|||||||
|
|
||||||
class AJAXHandler(BaseHandler):
|
class AJAXHandler(BaseHandler):
|
||||||
def get(self):
|
def get(self):
|
||||||
self.write("lol")
|
with open("image/temp.jpg", 'rb') as f:
|
||||||
|
data = f.read()
|
||||||
|
self.set_header('Content-type', 'image/jpg')
|
||||||
|
self.write(data)
|
||||||
|
self.finish()
|
||||||
|
|
||||||
|
|
||||||
application = tornado.web.Application([
|
application = tornado.web.Application([
|
||||||
|
14
video.html
14
video.html
@ -4,9 +4,21 @@
|
|||||||
<meta charset="utf8" />
|
<meta charset="utf8" />
|
||||||
<link rel="stylesheet" type="text/css" href="style/styles.css">
|
<link rel="stylesheet" type="text/css" href="style/styles.css">
|
||||||
<title>Acces camera</title>
|
<title>Acces camera</title>
|
||||||
|
<script type="text/javascript" >
|
||||||
|
|
||||||
|
$(document).ready( function() {
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url:'/ajax',
|
||||||
|
contentType: "image/jpg",
|
||||||
|
success: function(data){
|
||||||
|
$('.image').html('<img src="data:image/png;base64,' + data + '" />'); },
|
||||||
|
} );
|
||||||
|
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h2>Vue camera</h2>
|
<h2>Vue camera</h2>
|
||||||
<img href="image/temp.jpg" alt="image camera" />
|
<div id="image"></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Reference in New Issue
Block a user