Moved redirect functionality to extra class
This commit is contained in:
parent
c010709827
commit
a1b08ba10a
14
servefile
14
servefile
|
@ -37,14 +37,8 @@ def getDateStrNow():
|
||||||
now = datetime.datetime.fromtimestamp(time.mktime(time.gmtime()))
|
now = datetime.datetime.fromtimestamp(time.mktime(time.gmtime()))
|
||||||
return now.strftime("%a, %d %b %Y %H:%M:%S GMT")
|
return now.strftime("%a, %d %b %Y %H:%M:%S GMT")
|
||||||
|
|
||||||
class FileHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
class FileBaseHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
||||||
fileName = "Undefined"
|
fileName = "Undefined"
|
||||||
filePath = "/dev/null"
|
|
||||||
fileLength = 0
|
|
||||||
startTime = getDateStrNow()
|
|
||||||
blockSize = 1024 * 1024
|
|
||||||
|
|
||||||
|
|
||||||
def checkAndDoRedirect(self):
|
def checkAndDoRedirect(self):
|
||||||
""" If request didn't request self.fileName redirect to self.fileName.
|
""" If request didn't request self.fileName redirect to self.fileName.
|
||||||
|
|
||||||
|
@ -56,6 +50,12 @@ class FileHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
class FileHandler(FileBaseHandler):
|
||||||
|
filePath = "/dev/null"
|
||||||
|
fileLength = 0
|
||||||
|
startTime = getDateStrNow()
|
||||||
|
blockSize = 1024 * 1024
|
||||||
|
|
||||||
def do_HEAD(self):
|
def do_HEAD(self):
|
||||||
if self.checkAndDoRedirect():
|
if self.checkAndDoRedirect():
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue