Mercurial Hosting > luan
annotate website/src/examples/hi2.luan @ 567:6c00b8a59240
document Binary
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 05 Jul 2015 19:29:56 -0600 |
parents | 7bc63886d4f2 |
children | ca169567ce07 |
rev | line source |
---|---|
382 | 1 local Io = require "luan:Io" |
494
2b9bc97f0439
change luan:web to luan:http
Franklin Schmidt <fschmidt@gmail.com>
parents:
388
diff
changeset
|
2 local Http = require "luan:http/Http" |
382 | 3 |
388 | 4 |
382 | 5 local function form() |
6 %> | |
7 <html> | |
8 <body> | |
9 <h1>Hello</h1> | |
10 <form> | |
497
55f9f74f1e55
Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
495
diff
changeset
|
11 What is your name? |
388 | 12 <input name="name"> |
13 <input type=submit> | |
382 | 14 </form> |
15 </body> | |
16 </html> | |
17 <% | |
18 end | |
19 | |
503 | 20 local function hello(name) |
382 | 21 %> |
22 <html> | |
23 <body> | |
24 <h1>Hello</h1> | |
25 <p>Hi <%= name %>!</p> | |
26 </body> | |
27 </html> | |
28 <% | |
29 end | |
30 | |
505
7bc63886d4f2
web page modules now return a function
Franklin Schmidt <fschmidt@gmail.com>
parents:
503
diff
changeset
|
31 return function() |
382 | 32 Io.stdout = Http.response.text_writer() |
503 | 33 local name = Http.request.parameter.name |
382 | 34 if name == nil then |
35 form() | |
36 else | |
503 | 37 hello(name) |
382 | 38 end |
39 end |