mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-28 15:28:30 +00:00
Have redbean show zip listing as default / handler
If an "index.lua" or "index.html" doesn't exist in zip file or the filesystem, and no redirects have been defined for it either, then redbean will render a listing of the zip central directory content only if the request uri points to the root path.
This commit is contained in:
parent
ae300d0c40
commit
1753b669cf
10 changed files with 436 additions and 112 deletions
|
@ -1,6 +1,9 @@
|
|||
-- redbean lua server page demo
|
||||
|
||||
local function main()
|
||||
-- This is the best way to print data to the console or log file.
|
||||
Log(kLogWarn, "hello from \e[1mlua\e[0m!")
|
||||
|
||||
-- This check is pedantic but might be good to have.
|
||||
if GetMethod() ~= 'GET' and GetMethod() ~= 'HEAD' then
|
||||
ServeError(405)
|
||||
|
@ -19,6 +22,12 @@ local function main()
|
|||
Write('<title>redbean</title>\n')
|
||||
Write('<h1>redbean lua server page demo</h1>\n')
|
||||
|
||||
-- Prevent caching.
|
||||
-- We need this because we're doing things like putting the client's
|
||||
-- IP address in the response so we naturally don't want that cached
|
||||
SetHeader('Expires', FormatHttpDateTime(GetDate()))
|
||||
SetHeader('Cache-Control', 'no-cache, must-revalidate, max-age=0')
|
||||
|
||||
-- GetParams() returns an ordered list of Request-URI query params.
|
||||
Write('<h3>request uri parameters</h3>\n')
|
||||
params = GetParams()
|
||||
|
@ -100,10 +109,6 @@ local function main()
|
|||
Write('<dd>')
|
||||
Write(GetServerAddr())
|
||||
Write('\n')
|
||||
Write('<dt>FormatHttpDateTime(GetDate())\n')
|
||||
Write('<dd>')
|
||||
Write(FormatHttpDateTime(GetDate()))
|
||||
Write('\n')
|
||||
Write('</dl>\n')
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue