Closed GoogleCodeExporter closed 8 years ago
I would recommend you start with a simple cgi script that can be executed in
the Lua standalone interpreter
(http://luabinaries.sourceforge.net/download.html, e.g., Lua5.1.exe from
lua5_1_4_Win32_bin.zip). Make sure this executable is set as the CGI
interpreter in the mongoose.conf file (Option: I Lua5.1) and all paths are set
correctly. A short example script (lua.cgi) is below. This way you can
establish and test a connection between mongoose an Lua without making changes
in the source code of any of them.
Maybe taking the script below as a starting point and replacing the explicit
"print" calls by cgilua functions might help.
#!/usr/bin/lua5.1
-- First calculate response body, but do not send it yet
resp = [[
<http>
<head>
<title>Response of lua.cgi</title>
</head>
<body>
<h1>Response of lua.cgi:</h1>
<p>
]]
userName = os.getenv("REMOTE_USER")
if userName then
resp = resp .. "You are logged in as \"" .. userName .. "\".<br>";
else
resp = resp .. "You are not logged in.<br>";
end
resp = resp .. [[
</p>
</body>
</http>
]]
-- Now send a response head
print "Connection: close"
print "Content-Type: text/html; charset=utf-8"
print "Cache-Control: no-cache"
print ("Content-Length: " .. resp:len())
print ""
-- Finally send the response body
print (resp)
Original comment by bel2...@gmail.com
on 27 Feb 2012 at 3:00
Thanks Bel!
Original comment by valenok
on 22 Sep 2012 at 2:26
Original issue reported on code.google.com by
xueyaos...@gmail.com
on 3 Jan 2012 at 2:47Attachments: