No description
  • Lua 87.8%
  • CSS 6.1%
  • HTML 6.1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-09-21 23:30:24 +02:00
handlers This is a change 2026-09-21 23:30:24 +02:00
static Add a favicon, consolidate all the stuff into a single view. Autorefresh button added. 2026-08-16 15:09:21 +02:00
views This is a change 2026-09-21 23:30:24 +02:00
handlers.lua initial import 2026-08-16 00:52:25 +02:00
README.md readme by kimi 2026-08-16 00:55:36 +02:00
server.lua initial import 2026-08-16 00:52:25 +02:00

minilua-mvc

A mini MVC framework in pure Lua, served by Ncat's --lua-exec. Ships with a WireGuard control panel as the example app. No dependencies beyond ncat.

Requirements

  • ncat (from the nmap package)
  • wireguard-tools and root privileges (for the panel example)

Run

sudo ncat -l -k --lua-exec server.lua 8080

Then open http://localhost:8080/ — green button brings wg0 up, red brings it down, and the page shows the current wg status.

Layout

  • server.lua — the framework: HTTP parsing, routing, templates, static files. Never edit this to add a page.
  • handlers.lua — route index; dofiles the files in handlers/.
  • handlers/*.lua — routes registered into the global routes table. Key is "METHOD /path" (:name captures a path segment into request.params["name"]); the handler gets a request table (method, path, params, query, form) and returns the response body. redirect("/path") sends a 302.
  • views/*.html — templates: {{name}} escaped, {{{name}}} raw, {{>file.html}} include, {{#name}}...{{else}}...{{/name}} if-truthy, {{^name}}...{{/name}} if-falsy.
  • static/ — served as-is under /static/....

Adding a page

  1. Create handlers/foo.lua:

    routes["GET /foo"] = function(request)
        return render("foo.html", {["title"] = "Foo"})
    end
    
  2. Add dofile("handlers/foo.lua") to handlers.lua.

  3. Create views/foo.html.

Security notes

  • Only /static/... is served from disk; path traversal is rejected.
  • Never interpolate request data into io.popen() command strings.