fhttpy/modules/http/file-handlers/text.py

19 lines
391 B
Python
Raw Normal View History

2022-02-14 21:43:12 +00:00
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")