Mercurial Hosting > luan
diff website/src/tutorial.html.luan @ 1652:d5779a264a4a
docs work
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 31 Mar 2022 19:04:59 -0600 |
parents | 5b8f056527a3 |
children | 500c706ed4ea |
line wrap: on
line diff
--- a/website/src/tutorial.html.luan Thu Mar 31 16:13:32 2022 -0600 +++ b/website/src/tutorial.html.luan Thu Mar 31 19:04:59 2022 -0600 @@ -4,7 +4,7 @@ local Http = require "luan:http/Http.luan" local Shared = require "site:/lib/Shared.luan" local head = Shared.head or error() -local header = Shared.header or error() +local docs_header = Shared.docs_header or error() return function() @@ -17,7 +17,7 @@ <title>Luan Tutorial</title> </head> <body> -<% header{[[<a href="docs.html">Documentation</a>]]} %> +<% docs_header() %> <div content> <h1>Luan Tutorial</h1> @@ -91,7 +91,7 @@ end </pre> -<p>Now go back to the parent directory and do <b>luan luan:http/serve.luan src</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.html.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.html">http://localhost:8080/hi.html</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.luan src</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.html.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.html">http://localhost:8080/hi.html</a> then you will run the program which will generate the web page. In fact the page that you are currently looking at <b>tutorial.html</b> is generated from <a href="tutorial.html.luan">tutorial.html.luan</a>.</p> <p>The Luan webserver expects the file to return a function and calls it to generate the page. Code of the form <b>%>...<%</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 <code>text_writer</code> which writes its output to the HTTP response (to the web browser).</p>