[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to watch what wsapi.exe does?
- From: Gilles Ganault <gilles.ganault@...>
- Date: Thu, 20 May 2010 19:14:47 +0200
On Thu, 20 May 2010 19:05:25 +0200, Michal Kottman
<k0mpjut0r@gmail.com> wrote:
>CreateFile (despite it's name) is a Windows API function used to open a
>file for reading and/or writing. Maybe it is named like that because it
>'creates' a file handle.
Thanks guys. I have to go now, but I'll read the useful tips above so
I have a better grasp at how things work.
At this point, I have wsapi running, happily running hello.lua, but
I'm having the following issue after I copied hello.lua into
sqlite.lua to try to work with an SQLite database: The data is output
on the console, but not on the browser (save for the stuff from
hello.lua):
============= SCRIPT BASED ON hello.lua =============
require "luasql.sqlite3"
module("hello", package.seeall)
function run(wsapi_env)
local headers = { ["Content-type"] = "text/html" }
local function hello_text()
env = luasql.sqlite3()
conn = env:connect("test.sqlite")
assert(conn:execute("create table if not exists tbl1(one
varchar(10), two smallint)"))
assert(conn:execute("insert into tbl1 values('hello!',10)"))
assert(conn:execute("insert into tbl1 values('goodbye',20)"))
cursor = assert(conn:execute("select * from tbl1"))
row = {}
while cursor:fetch(row) do
print(table.concat(row, '|') .. '<br>')
end
cursor:close()
conn:close()
env:close()
-----------------------------------------------------------------------------
COMMENTED OUT BY MYSELF
coroutine.yield("<html><body>")
coroutine.yield("<p>Hello Wsapi!</p>")
coroutine.yield("<p>PATH_INFO: " .. wsapi_env.PATH_INFO .. "</p>")
coroutine.yield("<p>SCRIPT_NAME: " .. wsapi_env.SCRIPT_NAME ..
"</p>")
coroutine.yield("</body></html>")
-----------------------------------------------------------------------------
end
return 200, headers, coroutine.wrap(hello_text)
end
return _M
============= URL =============
http://localhost:9999/sqlite.lua
============= BROWSER =============
Hello Wsapi!
PATH_INFO: /
SCRIPT_NAME: /sqlite.lua
============= CONSOLE =============
C:\TEMP>wsapi -p9999
[Xavante launcher] Starting Xavante...
[2010-05-20 19:07:52] Xavante started on port(s) 9999
hello!|10<br>
goodbye|20<br>
hello!|10<br>
goodbye|20<br>
hello!|10<br>
goodbye|20<br>
hello!|10<br>
goodbye|20<br>
hello!|10<br>
goodbye|20<br>
hello!|10<br>
goodbye|20<br>
hello!|10<br>
goodbye|20<br>
hello!|10<br>
goodbye|20<br>
=============
FYI, C:\>TEMP\test.sqlite is successfully created and populated, so I
guess the problem is strictly about sending the output to the browser.
Thanks for any tip.