382
|
1 local Io = require "luan:Io"
|
|
2 local Http = require "luan:web/Http"
|
|
3
|
|
4 local function form()
|
|
5 %>
|
|
6 <html>
|
|
7 <body>
|
|
8 <h1>Hello</h1>
|
|
9 <form>
|
|
10 What is you name?
|
|
11 <input name="name">
|
|
12 <input type=submit>
|
|
13 </form>
|
|
14 </body>
|
|
15 </html>
|
|
16 <%
|
|
17 end
|
|
18
|
|
19 local function hello()
|
|
20 %>
|
|
21 <html>
|
|
22 <body>
|
|
23 <h1>Hello</h1>
|
|
24 <p>Hi <%= name %>!</p>
|
|
25 </body>
|
|
26 </html>
|
|
27 <%
|
|
28 end
|
|
29
|
|
30 function service()
|
|
31 Io.stdout = Http.response.text_writer()
|
|
32 name = Http.request.parameters.name
|
|
33 if name == nil then
|
|
34 form()
|
|
35 else
|
|
36 hello()
|
|
37 end
|
|
38 end
|