2022-02-14 21:43:12 +00:00
|
|
|
global handleText
|
|
|
|
def handleText(env):
|
2022-06-21 01:30:07 +00:00
|
|
|
filePath = env["fPath"]
|
2022-02-14 21:43:12 +00:00
|
|
|
data = b""
|
2022-06-21 01:30:07 +00:00
|
|
|
lastModified = None
|
2022-02-14 21:43:12 +00:00
|
|
|
with fileLock:
|
|
|
|
with open(env["fPath"],"rb") as textFile:
|
|
|
|
data = textFile.read()
|
2022-06-08 09:21:12 +00:00
|
|
|
try:
|
|
|
|
lastModified = os.path.getmtime(filePath)
|
|
|
|
except:
|
|
|
|
pass
|
2022-06-21 01:30:07 +00:00
|
|
|
|
|
|
|
headers = {
|
|
|
|
"Content-Type": mimetypesText[env["fileExt"]]+ "; charset=UTF-8",
|
|
|
|
"Accept-Ranges": "none",
|
|
|
|
"Date": env["requestTimeFormatted"]
|
|
|
|
}
|
|
|
|
|
|
|
|
if lastModified != None:
|
|
|
|
headers["Last-Modified"] = email.utils.formatdate(lastModified).replace("-0000","GMT")
|
2022-02-14 21:43:12 +00:00
|
|
|
|
|
|
|
simpleResponse(
|
2022-06-21 01:30:07 +00:00
|
|
|
env["self"].connection,"200 OK",headers,data
|
2022-02-14 21:43:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
for t in mimetypesText:
|
|
|
|
fileHandlers[t] = handleText
|
|
|
|
|
|
|
|
indexFiles.append("index.html")
|