modifié: superTornado.py
modifié: video.html
This commit is contained in:
parent
eb6434e84e
commit
884ab14b45
@ -51,12 +51,8 @@ class VideoHandler(BaseHandler):
|
||||
return
|
||||
name = tornado.escape.xhtml_escape(self.current_user)
|
||||
urlretrieve('http://test:a@192.168.1.15/image.jpg?cidx=791836195', 'image/temp.jpg')
|
||||
self.write("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()
|
||||
self.render("video.html")
|
||||
|
||||
|
||||
class UnauthorizedHandler(BaseHandler):
|
||||
def get(self):
|
||||
@ -80,7 +76,11 @@ class UnauthorizedHandler(BaseHandler):
|
||||
|
||||
class AJAXHandler(BaseHandler):
|
||||
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([
|
||||
|
14
video.html
14
video.html
@ -4,9 +4,21 @@
|
||||
<meta charset="utf8" />
|
||||
<link rel="stylesheet" type="text/css" href="style/styles.css">
|
||||
<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>
|
||||
<body>
|
||||
<h2>Vue camera</h2>
|
||||
<img href="image/temp.jpg" alt="image camera" />
|
||||
<div id="image"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user