2022-02-14 21:43:12 +00:00
|
|
|
global handleText
|
|
|
|
def handleText(env):
|
|
|
|
data = b""
|
2022-06-08 09:21:12 +00:00
|
|
|
lastModified = 0
|
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
|
|
|
|
lastModified = email.utils.formatdate(lastModified).replace("-0000","GMT")
|
2022-02-14 21:43:12 +00:00
|
|
|
|
|
|
|
simpleResponse(
|
|
|
|
env["self"].connection,"200 OK",
|
|
|
|
{
|
|
|
|
"Content-Type": mimetypesText[env["fileExt"]]+ "; charset=UTF-8",
|
2022-06-08 09:21:38 +00:00
|
|
|
"Accept-Ranges": "none",
|
2022-06-08 09:21:12 +00:00
|
|
|
"Date": env["requestTimeFormatted"],
|
|
|
|
"Last-Modified": lastModified
|
2022-02-14 21:43:12 +00:00
|
|
|
},data
|
|
|
|
)
|
|
|
|
|
|
|
|
for t in mimetypesText:
|
|
|
|
fileHandlers[t] = handleText
|
|
|
|
|
|
|
|
indexFiles.append("index.html")
|