Zuendi
Zuendi

Reputation: 149

Sending parameters from html to lua

this is probably an easy question but until now I could not find a way how to do it. I have an html website which calls a lua file:

<meta http-euqiv="refresh" content="0; URL=/cgi-bin/myTest.lua" />

This works just fine but I would like to add some arguments to the lua script but can figure out how. I tried something like this but I could not get my hands on the URL in the lua script:

<meta http-euqiv="refresh" content="0; URL=/cgi-bin/myTest.lua?test=6&test2=3" />

Do you have an idea? Thanks

Upvotes: 2

Views: 925

Answers (1)

lhf
lhf

Reputation: 72422

In a CGI script, the arguments of a GET submission are collected in a query string, which is available at the environment variable QUERY_STRING.

To read this variable in Lua, use os.getenv("QUERY_STRING").

You will need to parse the string; gsub and gmatch can help you there.

Upvotes: 1

Related Questions