comparison http/src/luan/modules/http/run.luan @ 505:7bc63886d4f2

web page modules now return a function
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 21 May 2015 01:45:49 -0600
parents 92c3d22745b8
children 6e3f063b71b5
comparison
equal deleted inserted replaced
504:dbdf4b8193a8 505:7bc63886d4f2
5 local print = Io.print 5 local print = Io.print
6 local Http = require "luan:http/Http" 6 local Http = require "luan:http/Http"
7 local String = require "luan:String" 7 local String = require "luan:String"
8 local Html = require "luan:Html" 8 local Html = require "luan:Html"
9 9
10 local M = {}
11 10
12 local function lines(s) 11 local function lines(s)
13 local matcher = s.gmatch "([^\n]*)\n|([^\n])+$" 12 local matcher = s.gmatch "([^\n]*)\n|([^\n])+$"
14 return function() 13 return function()
15 local m1, m2 = matcher() 14 local m1, m2 = matcher()
47 <% Html.simply_html_body_bottom() %> 46 <% Html.simply_html_body_bottom() %>
48 </body> 47 </body>
49 </html> 48 </html>
50 <% end 49 <% end
51 50
52 function M.respond() 51 return function()
53 Io.stdout = Http.response.text_writer() 52 Io.stdout = Http.response.text_writer()
54 local code = Http.request.parameter.code 53 local code = Http.request.parameter.code
55 if code == nil then 54 if code == nil then
56 form() 55 form()
57 return 56 return
76 print() 75 print()
77 print_with_line_numbers(code) 76 print_with_line_numbers(code)
78 end; 77 end;
79 } 78 }
80 end 79 end
81
82 return M