lua (wsapi と uWSGI) を使用した Web 開発を学んでいます。リクエスト オブジェクト ( https://keplerproject.github.io/wsapi/libraries.html ) を作成して、その外観 (および使用方法) を確認しようとしています。だから私はサンプルコードを設定しました:
require "wsapi.cgi"
function run(wsapi_env)
local headers = { ["Content-type"] = "text/html" }
local function hello_text()
local result = "<html><body>\n"
result = result .. "<p> Hello Wsapi !</p>\n"
result = result .. "<p>PATH_INFO wsapi_env: " .. wsapi_env.PATH_INFO .. "</p>\n"
-- problematic code
local req = wsapi.request.new(wsapi_env)
if req
then
--condition to see if req was nill
result = result .. "<p>PATH INFO_POST : " .. req.POST .. "</p>\n"
result = result .. "<p>PATH INFO_GET : " .. req.GET .. "</p>\n"
else
result = result .. "<p> No request <\p>\n"
end
-- end of the problematic code
result = result .. "<p><form method=\"post\" action=\"hello.lua\">\n"
result = result .. "<textarea name=\"message\"> test </textarea>\n"
result = result .. "</form></p>\n"
result = result .. "</body></html>\n"
coroutine.yield(result)
end
return 200, headers, coroutine.wrap(hello_text)
end
return run
しかし、リクエスト オブジェクトを使用すると、クライアントは空白のページを受け取ります。
リクエスト オブジェクトを作成して使用するにはどうすればよいですか?
回答ありがとうございます。
追加の質問: 別のページ (同じドメインの静的ページ) にリダイレクトするにはどうすればよいですか?