Mercurial Hosting > luan
diff website/src/tutorial.html.luan @ 494:2b9bc97f0439
change luan:web to luan:http
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 15 May 2015 17:43:13 -0600 |
parents | 322c03d85ada |
children | 598123096772 |
line wrap: on
line diff
--- a/website/src/tutorial.html.luan Fri May 15 17:29:59 2015 -0600 +++ b/website/src/tutorial.html.luan Fri May 15 17:43:13 2015 -0600 @@ -1,6 +1,6 @@ local Io = require "luan:Io" local Html = require "luan:Html" -local Http = require "luan:web/Http" +local Http = require "luan:http/Http" local Shared = require "site:/Shared" @@ -72,7 +72,7 @@ <p><tt><pre><%=Html.encode[[ local Io = require "luan:Io" - local Http = require "luan:web/Http" + local Http = require "luan:http/Http" function service() Io.stdout = Http.response.text_writer() @@ -86,7 +86,7 @@ end ]]%></pre></tt></p> -<p>Now go back to the parent directory and do <b>luan luan:web/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>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>service</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>service</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>