annotate website/src/examples/hi2.html.luan @ 1384:f5368cd8c056

remove template expressions and String.concat
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 15 Aug 2019 14:33:35 -0600
parents 4c2972f4d862
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3
388
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
4
382
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local function form()
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 %>
1178
49cf706c326a serve_for_nginx on port 8081
Franklin Schmidt <fschmidt@gmail.com>
parents: 1152
diff changeset
7 <!doctype html>
382
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 <html>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 <body>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 <h1>Hello</h1>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 <form>
497
55f9f74f1e55 Http.request is now pure luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 495
diff changeset
12 What is your name?
388
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
13 <input name="name">
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
14 <input type=submit>
382
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 </form>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 </body>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 </html>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 <%
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 end
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20
503
92c3d22745b8 make _ENV optional
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
21 local function hello(name)
382
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 %>
1216
5dbb552075ff doctype
Franklin Schmidt <fschmidt@gmail.com>
parents: 1178
diff changeset
23 <!doctype html>
382
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 <html>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 <body>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 <h1>Hello</h1>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 <p>Hi <%= name %>!</p>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 </body>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 </html>
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 <%
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 end
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32
505
7bc63886d4f2 web page modules now return a function
Franklin Schmidt <fschmidt@gmail.com>
parents: 503
diff changeset
33 return function()
382
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 Io.stdout = Http.response.text_writer()
1152
21d157b153fe change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents: 693
diff changeset
35 local name = Http.request.parameters.name
382
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 if name == nil then
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 form()
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 else
503
92c3d22745b8 make _ENV optional
Franklin Schmidt <fschmidt@gmail.com>
parents: 497
diff changeset
39 hello(name)
382
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40 end
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
41 end