Lua/WebDevelopment - How to get URL variables?

2019-07-25 12:02发布

问题:

I'm using Lua for web development.

How do I retrieve URL (get) variables?


For example http://example.com/?varA=999

Psuedo Lua code:

local varA = url.get(varA);  -- varA = 

回答1:

Lua's standard library doesn't do networking. Check out LuaSocket.



回答2:

If you are running your Lua code in Lua, you can use request_path() and request_uri() to read the URL, and global _GET for a parsed version that correspond to the URL get variables you mention.



标签: url lua