Lua functionality change: print renamed to mg.write, read renamed to mg.read. Expanded user manual, fixed example pages.

This commit is contained in:
Sergey Lyubka
2013-05-15 17:42:34 +01:00
parent d72645bf91
commit 2e232b3304
6 changed files with 311 additions and 334 deletions
+11 -13
View File
@@ -1,8 +1,5 @@
<?
-- Lua server pages have full control over the output, including HTTP
-- headers they send to the client. Send HTTP headers:
print('HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n')
?>
HTTP/1.0 200 OK
Content-Type: text/html
<html>
<p>Prime numbers from 0 to 100, calculated by Lua:</p>
@@ -18,7 +15,7 @@
end
for i = 1, 100 do
if is_prime(i) then print('<span>' .. i .. '</span>&nbsp;') end
if is_prime(i) then mg.write('<span>' .. i .. '</span>&nbsp;') end
end
?>
@@ -27,15 +24,16 @@
<form method="POST" ><input type="text" name="t1"/><input type="submit"></form>
<pre>
POST data: [<? print(read())?>]
request method: [<? print(request_info.request_method) ?>]
IP/port: [<? print(request_info.remote_ip, ':', request_info.remote_port) ?>]
URI: [<? print(request_info.uri) ?>]
HTTP version [<? print(request_info.http_version) ?>]
POST data: [<? mg.write(mg.read())?>]
request method: [<? mg.write(mg.request_info.request_method) ?>]
IP/port: [<? mg.write(mg.request_info.remote_ip, ':',
mg.request_info.remote_port) ?>]
URI: [<? mg.write(mg.request_info.uri) ?>]
HTTP version [<? mg.write(mg.request_info.http_version) ?>]
HEADERS:
<?
for name, value in pairs(request_info.http_headers) do
print(name, ':', value, '\n')
for name, value in pairs(mg.request_info.http_headers) do
mg.write(name, ':', value, '\n')
end
?>
</pre>