Mercurial Hosting > luan
changeset 1647:7eddf1e990c0
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 22 Mar 2022 09:00:59 -0700 |
parents | 1828ed4ee75d |
children | 224af797b1f9 |
files | website/serve.sh website/src/tutorial.html |
diffstat | 2 files changed, 6 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
diff -r 1828ed4ee75d -r 7eddf1e990c0 website/serve.sh --- a/website/serve.sh Wed Mar 09 15:40:12 2022 -0700 +++ b/website/serve.sh Tue Mar 22 09:00:59 2022 -0700 @@ -1,1 +1,1 @@ -luan luan:http/serve.luan file:src 2>&1 | tee err +luan luan:http/serve.luan src 2>&1 | tee err
diff -r 1828ed4ee75d -r 7eddf1e990c0 website/src/tutorial.html --- a/website/src/tutorial.html Wed Mar 09 15:40:12 2022 -0700 +++ b/website/src/tutorial.html Tue Mar 22 09:00:59 2022 -0700 @@ -49,7 +49,7 @@ <p>The <b>require</b> function takes a <a href="http://en.wikipedia.org/wiki/Uniform_resource_identifier">URI</a> as an argument. Examples of URIs are "<b>luan:Io.luan</b>" and "<b>file:hello.luan</b>". <b>require</b> is used to import a module, which is returned from the <b>require</b> function call. In the case above, we assign the module to the local variable <b>Io</b>. The function <b>print</b> is a member of this module. We could have done <b>Io.print("Hello World")</b> but instead we chose to assign <b>print</b> to a local variable and use that to call the function.</p> -<p>Luan starts with only two defined functions: <b>require</b> and <b>java</b>. You will use <b>require</b> to import whatever you need. This is a little more work, but makes it clear in each file where each function comes from.</p> +<p>Luan starts with only one defined function: <b>require</b>. You will use <b>require</b> to import whatever you need. This is a little more work, but makes it clear in each file where each function comes from.</p> <p>Let's a make fancier version:</p> @@ -66,7 +66,7 @@ <p>The <b>..</b> operator does concatenation. This will print <b>Hello Bob</b>.</p> -<p>Now let's make a web page. First we need a directory for our website. So create a directory <b>site</b>. In this directory, create a file <b>hi.html.luan</b> containing: +<p>Now let's make a web page. First we need a directory for our website. So create a directory <b>src</b>. In this directory, create a file <b>hi.html.luan</b> containing: <pre> local Io = require "luan:Io.luan" @@ -85,16 +85,16 @@ end </pre> -<p>Now go back to the parent directory and do <b>luan luan:http/serve.luan 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.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.</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> <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.</p> -<p>So now you have built your website and you want to publish it to the web. If you have your own domain, create a CNAME record for it pointing to <b>s1.luan.software</b>. If you don't have a domain, just use a domain like <b>bob.s1.luan.software</b> (anything of the form <b>*.s1.luan.software</b>). Assuming your directory is <b>site</b> and you will use the password <b>secret</b>, do the following from the command line: +<p>So now you have built your website and you want to publish it to the web. If you have your own domain, create a CNAME record for it pointing to <b>s1.luan.software</b>. If you don't have a domain, just use a domain like <b>bob.s1.luan.software</b> (anything of the form <b>*.s1.luan.software</b>). Assuming your directory is <b>src</b> and you will use the password <b>secret</b>, do the following from the command line: <pre> - luan luan:host/push.luan bob.s1.luan.software secret site + luan luan:host/push.luan bob.s1.luan.software secret src </pre> <p>The form is <b>luan luan:host/push.luan domain password directory</b>. If you change your site, just run this again and your site will be updated. To delete your site, do <b>luan luan:host/delete.luan domain password</b>.</p>