mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-08 08:54:54 +07:00
Lua functionality change: print renamed to mg.write, read renamed to mg.read. Expanded user manual, fixed example pages.
This commit is contained in:
@@ -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> ') end
|
||||
if is_prime(i) then mg.write('<span>' .. i .. '</span> ') 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>
|
||||
|
||||
Reference in New Issue
Block a user