Code cleanup
This commit is contained in:
parent
8620869e03
commit
77be4adcd0
15
servefile
15
servefile
|
@ -30,9 +30,8 @@ class FileHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
||||||
|
|
||||||
# find out if this is a continuing download
|
# find out if this is a continuing download
|
||||||
fromto = None
|
fromto = None
|
||||||
cont = self.headers.get("Range")
|
if "Range" in self.headers:
|
||||||
if cont != None:
|
cont = self.headers.get("Range").split("=")
|
||||||
cont = cont.split("=")
|
|
||||||
if len(cont) > 1 and cont[0] == 'bytes':
|
if len(cont) > 1 and cont[0] == 'bytes':
|
||||||
fromto = cont[1].split('-')
|
fromto = cont[1].split('-')
|
||||||
if len(fromto) > 1:
|
if len(fromto) > 1:
|
||||||
|
@ -73,7 +72,7 @@ class FileHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
||||||
return
|
return
|
||||||
|
|
||||||
def getChunk(self, myfile, fromto):
|
def getChunk(self, myfile, fromto):
|
||||||
if fromto != None and myfile.tell()+self.blockSize >= fromto[1]:
|
if fromto and myfile.tell()+self.blockSize >= fromto[1]:
|
||||||
readsize = fromto[1]-myfile.tell()+1
|
readsize = fromto[1]-myfile.tell()+1
|
||||||
else:
|
else:
|
||||||
readsize = self.blockSize
|
readsize = self.blockSize
|
||||||
|
@ -115,9 +114,11 @@ def main():
|
||||||
ips = commands.getoutput(r"/sbin/ifconfig |grep 'inet6\?'|grep -v 127.0.0.1|grep -v ' fe80'|grep -v ::1|sed -n 's/.*inet6\?[a-zA-Z: -]\+\([0-9a-fA-F.:]*\).*/\1/p'")
|
ips = commands.getoutput(r"/sbin/ifconfig |grep 'inet6\?'|grep -v 127.0.0.1|grep -v ' fe80'|grep -v ::1|sed -n 's/.*inet6\?[a-zA-Z: -]\+\([0-9a-fA-F.:]*\).*/\1/p'")
|
||||||
for ip in ips.split("\n"):
|
for ip in ips.split("\n"):
|
||||||
if ip.find(":") >= 0:
|
if ip.find(":") >= 0:
|
||||||
ip = "[%s]" % ip # must be v6...
|
# ipv6
|
||||||
continue # FIXME: When BaseHTTP supports ipv6 properly, delete this line
|
ip = "[%s]" % ip
|
||||||
print "http://%s:%d" % (ip, port)
|
# FIXME: When BaseHTTP supports ipv6 properly, delete this line
|
||||||
|
continue
|
||||||
|
print "http://%s:%d/" % (ip, port)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
server.serve_forever()
|
server.serve_forever()
|
||||||
|
|
Loading…
Reference in New Issue