http GET/PUT form data as input to lua or python?

#1
With some other servers I've used there were some built in functions for parsing and retrieving the key-value pairs from an http GET or POST form submission. For instance Mako web server has a request:data() function. You just enter local name = request:data("username") or local pwd = request:data("password") to store the entered form data in a Lua script variable.

I'm not at all clear on how Litespeed communicates with a Lua script, but I am hoping it is using something similar to LSAPI. Lua is actually my first choice for scripting with Litespeed. Does anyone know how to get submitted form data from Litespeed with Lua? Apparently Apache's mod_lua has a parseargs() function for GET and a parsebody() function for POST data. They store the data in a Lua table of course. The actual syntax seems to be "r: parseargs()" with the 'r' being from "function handle(r)" although I don't know what that means. Does Litespeed use a similar system?

Python is my second choice and I would probably end up mixing Python and Lua to some degree. I guess for Python scripts Litespeed uses WSGI, but I have been googling and that fact by itself does by no means make this an easy question to answer. I can find the PEP 0333 and 3333 standard, but I am still not clear on what to do in a Python script to actually store the key:value pairs from a GET/POST request in a variable. If anyone knows the answer to this or knows a web page or even a Python book that explains it I would be very grateful for that information.

Most of the answers I've seen focus on using Django or Flask or Bottle frameworks, but I don't have the RAM for Django on my VPS and I'd like to know if Python itself has a way to do this without using a framework. After further googling it seems that straight Python just isn't suitable for web applications. It seems like using a framework with Python is not optional. So I guess I would use something like Flask or Bottle. I sort of like Bottle from what I've read so far. Will these frameworks have any problem working with Litespeed? I can use whatever method the framework has for retrieving GET/POST data as long at it is WSGI compliant?

PHP makes this trivial with $_GET, $_POST, and $_REQUEST superglobals and with a syntax like $_GET['name'] it could not get any simpler. However I would prefer to use Lua or Python if I can for various reasons. Ruby is ugh too complicated for my tiny brain.
 
Last edited:
#3
Ok but I don't think Lua has any built in way to extract GET/POST data. Either Litespeed has some way to do this or I think (like Vanilla Python) it won't be possible to do without a specialized Lua Framework which is something I certainly had no intention of using, and I am not sure the LSAPI even applies to Lua. So I would like to know more about how Litespeed communicates with a Lua script. I pretty much assumed there would be some sort of API that would allow me to get form data if I knew the right syntax.
 

Pong

Administrator
Staff member
#4
For python, there should not be any difference.

For LUA, Currently, there is no LSAPI for LUA at the moment. You may not use LUA with LiteSpeed Enterprise. On OpenLiteSpeed side, an LUA module has been developed to support it.
https://openlitespeed.org/kb/openlitespeed-lua-module/

We may improve support for LUA in the future but I don't have any ETA for this yet.
 
Last edited:
Top