forked from dvv/luvit-static
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.lua
More file actions
executable file
·33 lines (29 loc) · 856 Bytes
/
test.lua
File metadata and controls
executable file
·33 lines (29 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env luvit
local Static = require('static')
local function makeHandler()
return require('stack').stack(
Static('/', {
-- root of static server
root = __dirname,
-- cache in the browser for 1 day
maxAge = 24*60*60*1000,
-- cache served files
isCacheable = function (fileStat)
-- analyze file stat?
-- return fileStat.size < 65536
-- or cache all
return true
end,
-- chunk size
chunkSize = 4096,
-- follow symlinks
follow = true,
-- redirect directories to underneath index.html
autoIndex = 'README.md',
-- uncomment to not redirect folders
-- redirectFolders = false,
})
)
end
require('http').createServer(makeHandler()):listen(8080, '0.0.0.0')
print('Static file server listening at http://localhost:8080/')