Mercurial Hosting > luan
annotate website/src/examples/hi2.luan @ 494:2b9bc97f0439
change luan:web to luan:http
| author | Franklin Schmidt <fschmidt@gmail.com> | 
|---|---|
| date | Fri, 15 May 2015 17:43:13 -0600 | 
| parents | 12ee9a336b95 | 
| children | 598123096772 | 
| rev | line source | 
|---|---|
| 382 | 1 local Io = require "luan:Io" | 
| 494 
2b9bc97f0439
change luan:web to luan:http
 Franklin Schmidt <fschmidt@gmail.com> parents: 
388diff
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> | |
| 388 | 11 What is you name? | 
| 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 | |
| 31 function service() | |
| 32 Io.stdout = Http.response.text_writer() | |
| 33 name = Http.request.parameters.name | |
| 34 if name == nil then | |
| 35 form() | |
| 36 else | |
| 37 hello() | |
| 38 end | |
| 39 end | 
