Basic CGI with Lua

I need a very lightweight web solution to run on a Linux device to handle HTML forms, so intend to use uwsgi and Lua.

The CGI script in this article uses the following code:

print ("Content-type: Text/html\n")
print ("Hello, world!")

However, this also works:

print("Status: 200 OK\r\n\r\nHello, world!\r\n")

I would like to know which CGI scripts are really needed to return to the web server.

Thank.

+3
source share
2 answers

You don’t need a heading at all, the only thing you really need is an empty line that ends the heading and starts the body:

print ("\nHello, World")

should also work.

, Content-type, , iso-8859-1, , utf-8, , , .

print("Content-type: text/html; charset=utf-8")

, , , , ,

print("Cache-control: no-cache")
print("Pragma: no-cache")

.

+2

HTML- (, POST). Ajax Forms (javascript library), POST JSON, io: read ('*') Lua script.

0

All Articles