modifié: superTornado.py
This commit is contained in:
parent
9059bd186b
commit
a34e34a854
@ -4,7 +4,8 @@ import tornado.httpserver
|
|||||||
import tornado.websocket
|
import tornado.websocket
|
||||||
import tornado.options
|
import tornado.options
|
||||||
import base64
|
import base64
|
||||||
from urllib import urlretrieve
|
import urllib2
|
||||||
|
#from urllib import urlretrieve
|
||||||
|
|
||||||
|
|
||||||
from tornado.ioloop import PeriodicCallback
|
from tornado.ioloop import PeriodicCallback
|
||||||
@ -75,14 +76,17 @@ class UnauthorizedHandler(BaseHandler):
|
|||||||
|
|
||||||
class AJAXHandler(BaseHandler):
|
class AJAXHandler(BaseHandler):
|
||||||
def post(self):
|
def post(self):
|
||||||
urlretrieve('http://test:a@192.168.1.15/image.jpg?cidx=791836195', 'image/temp.jpg')
|
if not self.current_user :
|
||||||
with open("image/temp.jpg", 'rb') as f:
|
self.redirect("/")
|
||||||
data = f.read()
|
return
|
||||||
#self.set_header('Content-type', 'image/jpeg')
|
data = urllib2.urlopen('http://test:a@192.168.1.15/image.jpg?cidx=791836195').read()
|
||||||
|
#urlretrieve('http://test:a@192.168.1.15/image.jpg?cidx=791836195', 'image/temp.jpg')
|
||||||
|
#with open("image/temp.jpg", 'rb') as f:
|
||||||
|
#data = f.read()
|
||||||
encoded = base64.b64encode(data)
|
encoded = base64.b64encode(data)
|
||||||
print encoded
|
print encoded
|
||||||
self.write(encoded)
|
self.write(encoded)
|
||||||
self.finish()
|
elf.finish()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user