xnhttpd
v0.8.0
xnhttpd {OPTIONS} [SETTING-JSON-PATH]
它在Localhost:8000上开始服务,并在当前目录上调用CGI脚本。
设置的JSON如下。
{
"handler" :{
".pl" : " c:/Program Files/Git/usr/bin/perl.exe "
},
"markdown" :{
"html" : true ,
"hardwrap" : true
}
}要使用示例Wiki Engine,请与Web-Browser打开http://127.0.0.1:8000/wiki.pl 。
当请求的URL后缀以.md结束并且文件存在时,嵌入式的Markdown查看器(GoldMark)运行。
如果{ "markdown":{ "html":true }}定义,则在*.md中可用raw-html-tags
当请求的URL后缀以.lua结尾,并且文件存在时,嵌入的Lua-Interpretor(Gopherlua)运行。
print ( " <html><body> " )
print ( " <h1>Embedded Lua Test</h1> " )
for _ , key in pairs {
" QUERY_STRING " ,
" CONTENT_LENGTH " ,
" REQUEST_METHOD " ,
" HTTP_COOKIE " ,
" HTTP_USER_AGENT " ,
" SCRIPT_NAME " ,
" REMOTE_ADDR " ,
} do
print ( string.format ( " <div>%s=%s</div> " , esc ( key ), esc ( _G [ key ])))
end
print ( " <hr /> " )
print ( string.format ( " <div>a=%s</div> " , esc ( get ( " a " ))))
print ( string.format ( [[
<form action="%s" method="post">
<div>New `a` value</div>
<div>
<input type="text" name="a" value="%s" />
<input type="submit" />
</div>
</form>
]] , esc ( SCRIPT_NAME ), esc ( get ( " a " ))))
local counter = cookie ( " counter " )
if counter and counter . value then
counter = { value = tonumber ( counter . value ) + 1 }
else
counter = { value = 1 }
end
setcookie ( " counter " , counter . value )
print ( " counter= " .. counter . value )
print ( " </body></html> " )从发行版中下载二进制包并提取可执行文件。
go install github.com/hymkor/xnhttpd
scoop install https://raw.githubusercontent.com/hymkor/xnhttpd/master/xnhttpd.json
或者
scoop bucket add hymkor https://github.com/hymkor/scoop-bucket
scoop install xnhttpd