-app.lua
local lapis = require("lapis")
local app=lapis.Application()
app:enable("etlua")
--数据库操作
---[[
local db=require ("lapis.db")
app:match("/", function()
local res = db.query("select * from testtable where id = ?", he)
return "ok! link success"
end)
---]]
--html布局登录注册界面
---[[
app.layout=require"views.layout"
---[[
app:get("/", function(self)
-- return "Welcome to Lapis " .. require("lapis.version")
--return {render="register"}
-- print(self.params)
return {render="index"}
end)
---]]
return app
--config.lua
local config = require("lapis.config")
--设置端口
config("development",{port=9090})
--数据库操作
---[[
local config = require("lapis.config")
config("development", {
mysql = {
host = "192.168.1.116",
user = "he",
password = "123456",
database = "mysql_test"
}
})
---]]
~
<html>
<meta charset="utf-8">
<body>
<div style="width:100%;text-align:center">
<h1>Version Managetment System </h>
<form action="">
<p style="color:#111111">username: <input type="text" id="name"></br>
password: <input type="password" id="password"></br></p>
<input type="button" value="登录"> <button>注册</button>
</form>
</div>
<script>
var input =ducument.getElementById("name")
console.log(input.value)
</script>
</body>
</html>
<!-- views/layout.etlua -->
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><%= page_title or "Version Managerment System" %></title>
</head>
<body>
<div class="text" style="text-align:center;"> <h1>版本管理系统</h1>
</div>
<% content_for("inner") %>
</body>
</html>
~