add fileToFileArray(...) function
This commit is contained in:
parent
6902236940
commit
393e06bb6c
8
esgd.py
8
esgd.py
|
@ -90,6 +90,12 @@ def notFound(context):
|
||||||
def invalid(context):
|
def invalid(context):
|
||||||
context.request.sendall(b"3error: selector contains '..'!\r\n.\r\n")
|
context.request.sendall(b"3error: selector contains '..'!\r\n.\r\n")
|
||||||
|
|
||||||
|
def fileToFileArray(file):
|
||||||
|
fd = open(file, "r")
|
||||||
|
ret = [i.rstrip() for i in fd.readlines()]
|
||||||
|
fd.close()
|
||||||
|
return ret
|
||||||
|
|
||||||
def sendFileArray(arr, context):
|
def sendFileArray(arr, context):
|
||||||
[context.request.sendall(
|
[context.request.sendall(
|
||||||
(i.rstrip() + "\r\n").encode("utf-8")
|
(i.rstrip() + "\r\n").encode("utf-8")
|
||||||
|
@ -128,7 +134,7 @@ def serveFile(file, query, gph, context):
|
||||||
if fileCGI(file):
|
if fileCGI(file):
|
||||||
fa = cgi(file, query, context)
|
fa = cgi(file, query, context)
|
||||||
elif fileSendable(file):
|
elif fileSendable(file):
|
||||||
fa = [i.rstrip() for i in open(file).readlines()]
|
fa = fileToFileArray(file)
|
||||||
else:
|
else:
|
||||||
notFound(context)
|
notFound(context)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue