def main(): args = args_handler('rf') filename = '' if args.filename: filename = args.filename if filename.startswith('http'): os.system('curl -O ' + filename) else: tmp = base64.b64decode(filename) url = "http://" + zlib.decompress(tmp) print url os.system('curl -O ' + url)
def main(): args = args_handler("sf") global httpd global filename global is_shutdown global alive PORT = 8410 ALIVE_TIME = 30 if args.alive: alive = args.alive ALIVE_TIME = 1200 if args.port: PORT = args.port while check_port_in_use(PORT): PORT = PORT + 1 filename = "" if args.filename: filename = args.filename ip = get_lan_ip() address = ip + ":" + str(PORT) + "/" + filename print "http://" + address z = zlib.compress(address) result = base64.b64encode(z) print result cmd = 'echo "%s" | pbcopy ' % result if sys.platform == "darwin": os.system(cmd) Handler = MyHandler httpd = MyTCPServer(("", PORT), Handler) print "serving at port", PORT thread.start_new_thread(httpd.serve_forever, ()) try: for x in xrange(1, ALIVE_TIME): if is_shutdown: exit() time.sleep(1) except (KeyboardInterrupt, SystemExit): print "exit" exit()