logging.basicConfig(level=logging.DEBUG) def app(environ, start_response): start_response('200 OK', []) path = environ['PATH_INFO'] if path == '/init': ret = json.dumps({'width':400, 'height':300, 'title':"Douban Radio", 'url': '/', }) elif path == '/': ret = """<html> <head> <title>OneRing测试</title> <script type="text/javascript" src="onering://onering/onering.js"></script> </head> <body> <img src="http://www.douban.com/pics/logosmall.gif" /> <br/> <a href="#" onclick="javascript:ONERING.getCurrentWindow().createWindow('/', 100, 100);return false">创建新窗口</a> </body> </html> """ else: ret = "" return [ret] onering.register_wsgi_app('test', app) onering.loop("test")
class static: def GET(self, filename): content = open('static/%s' % filename, 'rb').read() content_types = { '.js': 'text/javascript', '.css': 'text/css', '.ico': 'image/x-icon', } ext = os.path.splitext(filename)[1] content_type = content_types.get(ext, 'application/octet-stream') web.header('Content-Type', content_type) web.header('Content-Length', len(content)) return content if '-v' in sys.argv: logging.basicConfig(level=logging.DEBUG) else: logging.basicConfig() if '--demo' in sys.argv: startup_demo = sys.argv[sys.argv.index('--demo') + 1] else: startup_demo = None app = web.application(urls, globals(), autoreload=True) if __name__ == '__main__': onering.register_wsgi_app("demo", app.wsgifunc()) onering.loop("demo")
def GET(self): j_msg = _py4weibo.get_weibo("3407911524933786") dict_msg = json.loads(j_msg); print '[baiku] start:' print datetime.datetime.now() j_msgs = _py4weibo.get_weibo_tree("", 50) print '[baiku] getweibotree:' print datetime.datetime.now() dict_msgs = json.loads(j_msgs); print '[baiku] parse:' print datetime.datetime.now() html = render.sinaweibodemo2(weibo=dict_msg,weibos=dict_msgs) print '[baiku] render:' print datetime.datetime.now() return html # ===========================================================> if '-v' in sys.argv: logging.basicConfig(level=logging.DEBUG) else: logging.basicConfig() if '--demo' in sys.argv: startup_demo = sys.argv[sys.argv.index('--demo')+1] else: startup_demo = None app = web.application(urls, globals(), autoreload=True) if __name__ == '__main__': onering.register_wsgi_app("pyweibo", app.wsgifunc()) onering.loop("pyweibo")
class static: def GET(self, filename): #print filename content = open('static/%s' % filename, 'rb').read() content_types = { '.js': 'text/javascript', '.css': 'text/css', '.ico': 'image/x-icon', } ext = os.path.splitext(filename)[1] content_type = content_types.get(ext, 'application/octet-stream') web.header('Content-Type', content_type) web.header('Content-Length', len(content)) return content if '-v' in sys.argv: logging.basicConfig(level=logging.DEBUG) else: logging.basicConfig() if '--demo' in sys.argv: startup_demo = sys.argv[sys.argv.index('--demo')+1] else: startup_demo = None app = web.application(urls, locals(), autoreload=True) if __name__ == '__main__': onering.register_wsgi_app("demo", app.wsgifunc()) onering.loop("demo")
start_response('200 OK', []) path = environ['PATH_INFO'] if path == '/init': ret = json.dumps({ 'width': 400, 'height': 300, 'title': "Douban Radio", 'url': '/', }) elif path == '/': ret = """<html> <head> <title>OneRing测试</title> <script type="text/javascript" src="onering://onering/onering.js"></script> </head> <body> <img src="http://www.douban.com/pics/logosmall.gif" /> <br/> <a href="#" onclick="javascript:ONERING.getCurrentWindow().createWindow('/', 100, 100);return false">创建新窗口</a> </body> </html> """ else: ret = "" return [ret] onering.register_wsgi_app('test', app) onering.loop("test")