微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Luvit Lua实现的Node.js

程序名称:Luvit

授权协议: MIT

操作系统: Linux

开发语言: Lua

Luvit 介绍

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

Luvit 官网

https://github.com/luvit/luvit

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐