2023-01-09 10:25:03 (UTC-03:00)
Marcel Rodrigues <marcelgmr@gmail.com>
add README
diff --git a/README.md b/README.md new file mode 100644 index 0000000..707cca9 --- /dev/null +++ b/README.md @@ -0,0 +1,65 @@ += ludweb + +This is a simple web framework for LuaJIT. + +Features: + * routing with regex parameter + * templates with branching, looping, % include + * extras: crypto hash for passwords, sqlite database + += hello world app + +``` +local lud = require "ludweb" + +lud.app.new_app{ + {"GET", "/?", function (req) return "Hello World!" end}, + {"GET", "/(%S+)", function (req, name) return "Hi "..name.."!" end} +}:run(8080) +``` + += request object + +TODO + += responses + +TODO + += templates + +``` +local lud = require "ludweb" + +local tpl = [[ + % if $users == nil then + <p>no users found</p> + % else + <ul> + % for user in $users do + <li><a href="{{$user.nick}}">{{$user.name}}</a></li> + % end + </ul> + % end +]] + +local users = { + {nick="john_smith", name="John Smith"}, + {nick="monteiro_lobato", name="Monteiro Lobato"}, + {nick="lima_barreto", name="Lima Barreto"} +} + +local str = lud.template.render_str(tpl, {users=users}) +print(str) +``` + +The function `render_file()` is similar to `render_str()`, +except that it takes a file name as first argument. + += crypto + +TODO + += sqlite + +TODO