diff website/src/tutorial.html.luan @ 512:d96944467ffc

update documentation for luan changes
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 22 May 2015 16:08:23 -0600
parents 7bc63886d4f2
children 7cc9d4a53d3b
line wrap: on
line diff
--- a/website/src/tutorial.html.luan	Fri May 22 10:47:56 2015 -0600
+++ b/website/src/tutorial.html.luan	Fri May 22 16:08:23 2015 -0600
@@ -59,7 +59,7 @@
 	local Io = require "luan:Io"
 	local print = Io.print
 
-	function hello(name)
+	local function hello(name)
 		print("Hello "..name)
 	end
 
@@ -74,7 +74,7 @@
 	local Io = require "luan:Io"
 	local Http = require "luan:http/Http"
 	
-	function respond()
+	return function()
 		Io.stdout = Http.response.text_writer()
 		%>
 		<html>
@@ -88,7 +88,7 @@
 
 <p>Now go back to the parent directory and do <b>luan luan:http/serve file:site</b>.  This will run the Luan web server on port 8080.  Try going to <a href="http://localhost:8080/">http://localhost:8080/</a>.  You should see the directory.  If you click on <b>hi.luan</b> you will see the source.  But if you remove the <b>.luan</b> and just go to <a href="http://localhost:8080/hi">http://localhost:8080/hi</a> then you will run the program which will generate the web page.</p>
 
-<p>The Luan webserver looks for function named <b>respond</b> in the file and calls it to generate the page.  Code of the form <b><%=Html.encode[[%>...<%]]%></b> writes its output to <b>Io.stdout</b> which by default is the standard output of the command line.  So in <b>respond</b> one usually starts by setting <b>Io.stdout</b> to a <tt>text_writer</tt> which writes its output to the HTTP response (to the web browser).</p>
+<p>The Luan webserver expects the file to return a function and calls it to generate the page.  Code of the form <b><%=Html.encode[[%>...<%]]%></b> writes its output to <b>Io.stdout</b> which by default is the standard output of the command line.  So in the returned function one usually starts by setting <b>Io.stdout</b> to a <tt>text_writer</tt> which writes its output to the HTTP response (to the web browser).</p>
 
 <p>You can find this example and others in the <a href="examples">examples directory</a>.  Take a look at <a href="examples/hi2.luan">hi2.luan</a> next.  Remember to remove the <b>.luan</b> from the URL to run the code.  And by the way, you can see the source for this page at <a href="tutorial.html.luan">tutorial.html.luan</a>.</p>