Luvit - Lua实现的Node.js


MIT
Linux
Lua

软件简介

Luvit - Lua + UV + Jit = NodeJS re-implemented in Lua

如上面标题所描述的,Luvit 相当于 luajit2 + libuv,编译成单个可执行文件,类似
Node.js ,可运行 .lua 文件。

示例代码(创建一个HTTP服务器)

-- Load the http library
local HTTP = require("lib/http")

-- Create a simple nodeJS style hello-world server
HTTP.create_server(function (req, res)
  res:write_head(200, {
    ["Content-Type"] = "text/plain",
    ["Content-Length"] = "11"
  })
  res:write("Hello World")
  res:finish()
end):listen(8080)

-- Give a friendly message
print("Server listening at http://localhost:8080/")