nodemcu-httpserver/httpserver-static.lua
Gregor Hartmann ca4fb20c00 Serve static pages efficiently. Fix #53 (#118)
* 1st draft to serve static files faster

* Allow serving 5 images in a page

the 6th image cannot be served as the esp does not open more than 5 connections at the same time

* win the prize

* Update comments
2019-11-14 11:58:56 -06:00

14 lines
443 B
Lua

-- httpserver-static.lua
-- Part of nodemcu-httpserver, handles sending static files to client.
-- Author: Gregor Hartmann
return function (connection, req, args)
local buffer = dofile("httpserver-buffer.lc"):new()
dofile("httpserver-header.lc")(buffer, req.code or 200, args.ext, args.isGzipped)
-- Send header and return fileInfo
connection:send(buffer:getBuffer())
return { file = args.file, sent = 0}
end