用户登录
用户注册

分享至

基于 aLi Lua Web Server 的一个简单例子

  • 作者: 蒋金龙39235736
  • 来源: 51数据库
  • 2021-08-12

复制代码 代码如下:

file = 'index.lua'
if headers.uri ~= '/' then file = headers.uri end
 
local fexists = file_exists(file)
 
if not fexists then
    -- try stat file.lua
    fexists = file_exists(file .. '.lua')
    if fexists then
        file = file .. '.lua'
    end
end
 
if fexists then
    if file:find('.css') or file:find('.js') or file:find('font') or file:find('.ico') or file:find('images') then
        header('http/1.1 200 ok')
        header('cache-control: max-age=864000')
        sendfile(file)
    else
        header({'expires:thu, 19 nov 1981 08:52:00 gmt',
                'pragma:no-cache'})
 
        dofile(file)
    end
else
    header('http/1.1 404 not found')
    die('file not found!')
end
 
die()

以上所述的全部内容了,希望大家能够喜欢。

软件
前端设计
程序设计
Java相关