Coder Social home page Coder Social logo

hymkor / xnhttpd Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 83 KB

CGI Server for test uses instead of ANHTTPD

License: MIT License

Go 63.54% Lua 4.14% CSS 27.21% Makefile 5.11%
go golang cgi cgi-application web-application httpd httpd-server anhttpd

xnhttpd's Introduction

xnhttpd

  • CGI Server for test uses instead of AN HTTPD
  • Markdown viewer
  • Lua Application Server (experimental)
xnhttpd {OPTIONS} [SETTING-JSON-PATH]
  • -C string
    • Working directory
  • -hardwrap
    • Enable hard wrap in *.md
  • -html
    • Enable raw htmls in *.md
  • -index string
    • the default page when URL is directory (default "index.html,README.md,INDEX.md")
  • -p uint
    • Port number (default 8000)
  • -perl
    • Enable Perl as handler for *.pl

which starts service on localhost:8000 and calls CGI scripts on the current directory.

The JSON for setting is like below.

{
	"handler":{
		".pl":"c:/Program Files/Git/usr/bin/perl.exe"
	},
	"markdown":{
		"html":true,
		"hardwrap":true
	}
}

To use sample wiki-engine, open http://127.0.0.1:8000/wiki.pl with web-browser.

Markdown Viewer

When the requested url's suffix ends with .md and the file exists, the embedded markdown viewer(goldmark) runs.

If { "markdown":{ "html":true }} is defined, raw-HTML-tags are available in *.md

Lua Application Server

When the requested url's suffix ends with .lua and the file exists, the embedded Lua-interpretor(GopherLua) runs.

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>")

Install

Download the binary package from Releases and extract the executable.

for scoop-installer

scoop install https://raw.githubusercontent.com/hymkor/xnhttpd/master/xnhttpd.json

or

scoop bucket add hymkor https://github.com/hymkor/scoop-bucket
scoop install xnhttpd

xnhttpd's People

Contributors

hymkor avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

isgasho

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.