annotate website/src/examples/hi2.luan @ 386:db23f654f87d

make all of website use luan
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 23 Apr 2015 18:09:12 -0600
parents 8557581740db
children 12ee9a336b95
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
382
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Io = require "luan:Io"
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local Http = require "luan:web/Http"
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 local function form()
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 %>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 <html>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 <body>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 <h1>Hello</h1>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 <form>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 What is you name?
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 <input name="name">
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 <input type=submit>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 </form>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 </body>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 </html>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 <%
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 end
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 local function hello()
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 %>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 <html>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 <body>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 <h1>Hello</h1>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 <p>Hi <%= name %>!</p>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 </body>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 </html>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 <%
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 end
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 function service()
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 Io.stdout = Http.response.text_writer()
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 name = Http.request.parameters.name
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 if name == nil then
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 form()
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 else
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 hello()
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 end
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 end