diff --git a/http/delorean.jpg b/http/delorean.jpg new file mode 100644 index 0000000..7caba4c Binary files /dev/null and b/http/delorean.jpg differ diff --git a/httpserver-static.lua b/httpserver-static.lua index c1a9579..ca73e30 100644 --- a/httpserver-static.lua +++ b/httpserver-static.lua @@ -4,7 +4,7 @@ local function getMimeType(ext) -- A few MIME types. Keep list short. If you need something that is missing, let's add it. - local mt = {css = "text/css",gif = "image/gif",html = "text/html",ico = "image/x-icon",jpeg = "image/jpeg",jpg = "image/jpeg",js = "application/javascript",png = "image/png"} + local mt = {css = "text/css", gif = "image/gif", html = "text/html", ico = "image/x-icon", jpeg = "image/jpeg", jpg = "image/jpeg", js = "application/javascript", josn="application/json", png = "image/png"} if mt[ext] then return mt[ext] else return "text/plain" end end @@ -13,16 +13,15 @@ local function sendHeader(connection, code, codeString, mimeType) end return function (connection, args) - print("Serving:", args.file) sendHeader(connection, 200, "OK", getMimeType(args.ext)) file.open(args.file) -- Send file in little chunks while true do - local chunk = file.read(512) + local chunk = file.read(1024) if chunk == nil then break end coroutine.yield() connection:send(chunk) end - print("Finished sending file.") + print("Finished sending:", args.file) file.close() end