Mercurial Hosting > luan
comparison website/src/tutorial.html.luan @ 1217:4c2972f4d862
.html in examples
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 20 Mar 2018 15:43:16 -0600 |
parents | 5dbb552075ff |
children | 5684a14582c4 |
comparison
equal
deleted
inserted
replaced
1216:5dbb552075ff | 1217:4c2972f4d862 |
---|---|
69 hello("Bob") | 69 hello("Bob") |
70 </pre> | 70 </pre> |
71 | 71 |
72 <p>The <b>..</b> operator does concatenation. This will print <b>Hello Bob</b>.</p> | 72 <p>The <b>..</b> operator does concatenation. This will print <b>Hello Bob</b>.</p> |
73 | 73 |
74 <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.luan</b> containing: | 74 <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: |
75 | 75 |
76 <pre><%=Html.encode[[ | 76 <pre><%=Html.encode[[ |
77 local Io = require "luan:Io.luan" | 77 local Io = require "luan:Io.luan" |
78 local Http = require "luan:http/Http.luan" | 78 local Http = require "luan:http/Http.luan" |
79 | 79 |
88 </html> | 88 </html> |
89 <% | 89 <% |
90 end | 90 end |
91 ]]%></pre> | 91 ]]%></pre> |
92 | 92 |
93 <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.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> | 93 <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> |
94 | 94 |
95 <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 <code>text_writer</code> which writes its output to the HTTP response (to the web browser).</p> | 95 <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 <code>text_writer</code> which writes its output to the HTTP response (to the web browser).</p> |
96 | 96 |
97 <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> | 97 <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> |
98 | 98 |
99 <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.luanhost.com</b>. If you don't have a domain, just use a domain like <b>bob.s1.luanhost.com</b> (anything of the form <b>*.s1.luanhost.com</b>). Assuming your directory is <b>site</b> and you will use the password <b>secret</b>, do the following from the command line: | 99 <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.luanhost.com</b>. If you don't have a domain, just use a domain like <b>bob.s1.luanhost.com</b> (anything of the form <b>*.s1.luanhost.com</b>). Assuming your directory is <b>site</b> and you will use the password <b>secret</b>, do the following from the command line: |
100 | 100 |
101 <pre> | 101 <pre> |
102 luan luan:host/push.luan bob.s1.luanhost.com secret site | 102 luan luan:host/push.luan bob.s1.luanhost.com secret site |