winlin

refine the proxy api server.

@@ -36,7 +36,7 @@ reload(sys) @@ -36,7 +36,7 @@ reload(sys)
36 exec("sys.setdefaultencoding('utf-8')") 36 exec("sys.setdefaultencoding('utf-8')")
37 assert sys.getdefaultencoding().lower() == "utf-8" 37 assert sys.getdefaultencoding().lower() == "utf-8"
38 38
39 -import os, json, time, datetime, cherrypy, threading 39 +import os, json, time, datetime, cherrypy, threading, urllib2
40 40
41 # simple log functions. 41 # simple log functions.
42 def trace(msg): 42 def trace(msg):
@@ -328,15 +328,20 @@ class RESTProxy(object): @@ -328,15 +328,20 @@ class RESTProxy(object):
328 ''' 328 '''
329 def GET(self, *args, **kwargs): 329 def GET(self, *args, **kwargs):
330 enable_crossdomain() 330 enable_crossdomain()
331 -  
332 - hls = {  
333 - "args": args,  
334 - "kwargs": kwargs  
335 - }  
336 331
337 - ret = json.dumps(hls)  
338 - print ret  
339 - return ret 332 + url = "http://" + "/".join(args);
  333 + print "start to proxy url: %s"%url
  334 +
  335 + f = None
  336 + try:
  337 + f = urllib2.urlopen(url)
  338 + f.read()
  339 + except:
  340 + print "error proxy url: %s"%url
  341 + finally:
  342 + if f: f.close()
  343 + print "completed proxy url: %s"%url
  344 + return url
340 345
341 ''' 346 '''
342 handle the hls requests: hls stream. 347 handle the hls requests: hls stream.