Upload files.

This commit is contained in:
n* 2025-02-21 22:43:52 -03:00
commit 75fe33b7ca
5 changed files with 76 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
deps/
luvi-luvit-example

29
README Normal file
View file

@ -0,0 +1,29 @@
# luddite
An example of a weblit app that works for both luvi and luvit,
using the lit package manager on the same codebase.
Mostly this was just an experiment, and I did it to figure this
out for my bigger project, [napkin](https://kitsune.dev/n/napkin).
## Setting it up
```
# Set luvi, luvit and lit up
curl -L https://github.com/luvit/lit/raw/master/get-lit.sh | sh
cp luvi luvit lit ~/.local/bin
# Get the repo
git clone https://kitsune.dev/n/luddite
cd luvi-luvit-example
# Install dependencies
lit install
# Run with Luvit
luvit main.lua # or app.lua
# Run with Luvi
luvi .
# Build with luvi
luvi . -o luddite
```

17
app.lua Normal file
View file

@ -0,0 +1,17 @@
local weblit = require('weblit')
weblit.app
.bind({ host = "127.0.0.1", port = 1337 })
-- Configure weblit server
.use(weblit.logger)
.use(weblit.autoHeaders)
.route({ path = "/" }, function(req, res)
res.body = "Wassup! Hello from luvi" .. (_G.is_luvit and "t" or "") .. "!"
res.code = 200
res.headers["Content-Type"] = "text/plain"
end)
-- Start the server
.start()

5
main.lua Normal file
View file

@ -0,0 +1,5 @@
_G.is_luvit = _G.process ~= nil
require("luvit")(function()
require("./app")
end)

23
package.lua Normal file
View file

@ -0,0 +1,23 @@
return {
name = "luddite",
version = "0.0.1",
description = "An example of weblit on luvi and luvit.",
tags = {
"lua", "lit", "luvit", "luvi", "weblit"
},
license = "MIT",
author = {
name = "Nelson Lopez",
email = "darltrash@icloud.com"
},
homepage = "https://kitsunes.club/n/luddite",
dependencies = {
"creationix/weblit",
"luvit/luvit"
},
files = {
"**.lua",
"deps/",
"!test*"
}
}