基于 aLi Lua Web Server 的一個(gè)簡(jiǎn)單例子
更新時(shí)間:2015年03月16日 17:19:34 投稿:hebedich
這篇文章主要介紹了基于 aLi Lua Web Server 的一個(gè)簡(jiǎn)單例子的代碼,非常簡(jiǎn)單,推薦給大家。
復(fù)制代碼 代碼如下:
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()
以上所述的全部?jī)?nèi)容了,希望大家能夠喜歡。
相關(guān)文章
vs2012 error c4996: This function or variable may be unsafe
這篇文章主要介紹了vs2012 error c4996: This function or variable may be unsafe,需要的朋友可以參考下2015-04-04Lua腳本實(shí)現(xiàn)遞歸刪除一個(gè)文件夾
這篇文章主要介紹了Lua腳本實(shí)現(xiàn)遞歸刪除一個(gè)文件夾,本文給出了C++和Lua兩個(gè)版本的實(shí)現(xiàn)代碼,需要的朋友可以參考下2015-05-05Cocos2d-x中調(diào)用Lua及HelloWorld.lua源碼分解
這篇文章主要介紹了Cocos2d-x中調(diào)用Lua及HelloWorld.lua源碼分解,本文最后總結(jié)了一些Lua的語(yǔ)法,需要的朋友可以參考下2014-09-09