Mercurial Hosting > luan
annotate website/src/examples/hi2.luan @ 501:f26485a3692c
add String.literal to quote regex
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Mon, 18 May 2015 23:23:01 -0600 |
| parents | 55f9f74f1e55 |
| children | 92c3d22745b8 |
| 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 | |
| 20 local function hello() | |
| 21 %> | |
| 22 <html> | |
| 23 <body> | |
| 24 <h1>Hello</h1> | |
| 25 <p>Hi <%= name %>!</p> | |
| 26 </body> | |
| 27 </html> | |
| 28 <% | |
| 29 end | |
| 30 | |
|
495
598123096772
rename service() to respond()
Franklin Schmidt <fschmidt@gmail.com>
parents:
494
diff
changeset
|
31 function respond() |
| 382 | 32 Io.stdout = Http.response.text_writer() |
|
497
55f9f74f1e55
Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents:
495
diff
changeset
|
33 name = Http.request.parameter.name |
| 382 | 34 if name == nil then |
| 35 form() | |
| 36 else | |
| 37 hello() | |
| 38 end | |
| 39 end |
