fhttpy/modules/http/file-handlers/text.py
2022-02-14 22:43:12 +01:00

19 lines
391 B
Python

global handleText
def handleText(env):
data = b""
with fileLock:
with open(env["fPath"],"rb") as textFile:
data = textFile.read()
simpleResponse(
env["self"].connection,"200 OK",
{
"Content-Type": mimetypesText[env["fileExt"]]+ "; charset=UTF-8",
"Accept-Ranges": "bytes"
},data
)
for t in mimetypesText:
fileHandlers[t] = handleText
indexFiles.append("index.html")