兼容linux

This commit is contained in:
xx
2024-05-28 15:12:37 +08:00
parent b8b2ff12bf
commit bdbe5f34dd
34 changed files with 331 additions and 713 deletions

View File

@@ -1,17 +1,10 @@
require "website"
-- 通用入口函数
route = {"/",GET}
function access()
-- MYSQL执行SELECT查询map表
--local result = mysql:select():table("map"):query()
-- 构建回复数据
--local data = result:table()
local data = {
name = "Fast Web 快速网站开发框架"
}
-- 返回JSON数据
json(data)
reply(200,"OK",data)
end

View File

@@ -1,19 +1,6 @@
require "website"
-- MYSQL数据库池
function initMysql()
local pool = mysql_pool.new()
if pool:start("127.0.0.1","test","123456","test","utf8mb4",3306,10) == false then
print("start mysql pool failed")
return false
end
global_regist("mysql",pool:self())
return true
end
print("init fast web success!")
if initMysql() == false then
return false
end
return true

View File

@@ -1,9 +1,7 @@
function access()
if request:pstring("key") == "123456" then
return true
require "website"
function access()
if param("key") == nil or param("key") ~= "123465" then
print("is not found key")
end
response:send("密钥不正确,已被拦截器拦截.")
return false
return true
end

View File

@@ -1,8 +1,23 @@
local dkjson = require 'dkjson'
function json(data)
response:header("Content-Type","application/json")
response:send(dkjson.encode(data))
end
function session()
return request:session(request:token())
end
function param(name)
return request:param(name,false)
end
function param_throw(name)
return request:param(name,true)
end
function reply(code,msg,data)
local data ={
code =code,
msg = msg,
data = data
}
json(data)
end