comparison website/src/examples/hi2.html.luan @ 1217:4c2972f4d862

.html in examples
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 20 Mar 2018 15:43:16 -0600
parents website/src/examples/hi2.luan@5dbb552075ff
children
comparison
equal deleted inserted replaced
1216:5dbb552075ff 1217:4c2972f4d862
1 local Io = require "luan:Io.luan"
2 local Http = require "luan:http/Http.luan"
3
4
5 local function form()
6 %>
7 <!doctype html>
8 <html>
9 <body>
10 <h1>Hello</h1>
11 <form>
12 What is your name?
13 <input name="name">
14 <input type=submit>
15 </form>
16 </body>
17 </html>
18 <%
19 end
20
21 local function hello(name)
22 %>
23 <!doctype html>
24 <html>
25 <body>
26 <h1>Hello</h1>
27 <p>Hi <%= name %>!</p>
28 </body>
29 </html>
30 <%
31 end
32
33 return function()
34 Io.stdout = Http.response.text_writer()
35 local name = Http.request.parameters.name
36 if name == nil then
37 form()
38 else
39 hello(name)
40 end
41 end