I need a very light web solution to run on a Linux appliance to handle HTML forms, so intend to use uwsgi and Lua.
In the CGI script, this article uses the following code:
print ("Content-type: Text/html\n")
print ("Hello, world!")
However, this works too:
print("Status: 200 OK\r\n\r\nHello, world!\r\n")
I'd like to know what CGI scripts are really required to return to the web server.
Thank you.
You don't need a header at all, the only thing you really need is the blank line that ends the header and starts the body:
print ("\nHello, World")
should work as well.
However, you should at least include the Content-type including the character set, since browsers should default to iso-8859-1, but the user may override this, and you should use utf-8 to avoid being restricted in what characters you can display.
print("Content-type: text/html; charset=utf-8")
Also, if you're programming an appliance, you probably want to avoid caching, so i'd spend an extra
print("Cache-control: no-cache")
print("Pragma: no-cache")
which prevents browsers and proxies from caching your page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With