Mercurial Hosting > luan
annotate website/src/examples/hi2.luan @ 1125:442abdfff437
include luan stack in LuanException.printStackTrace()
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Thu, 24 Aug 2017 14:03:36 -0600 |
| parents | ca169567ce07 |
| children | 21d157b153fe |
| rev | line source |
|---|---|
|
693
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
505
diff
changeset
|
1 local Io = require "luan:Io.luan" |
|
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
505
diff
changeset
|
2 local Http = require "luan:http/Http.luan" |
| 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 |
