webmcp
view framework/cgi-bin/webmcp-wrapper.lua @ 31:1cd9e69b85cb
add execute.load_chunk(args)
load_chunk loads the content of a lua file and returns the code.
It can construct the path name easily so you can put helper code in
seperate files for DRYness.
load_chunk loads the content of a lua file and returns the code.
It can construct the path name easily so you can put helper code in
seperate files for DRYness.
| author | Daniel Poelzleithner <poelzi@poelzi.org> | 
|---|---|
| date | Tue Oct 05 02:34:04 2010 +0200 (2010-10-05) | 
| parents | 9fdfb27f8e67 | 
| children | 
 line source
     1 #!/usr/bin/env lua
     3 local func, errmsg = loadfile('webmcp.lua')
     5 if func then
     6   local result
     7   result, errmsg = pcall(func)
     8   if result then
     9     errmsg = nil
    10   end
    11 end
    13 if errmsg and not (cgi and cgi.data_sent) then
    14   print('Status: 500 Internal Server Error')
    15   print('Content-type: text/plain')
    16   print()
    17   print('500 Internal Server Error')
    18   print()
    19   print(errmsg)
    20   print()
    21   print('(caught by webmcp-wrapper.lua)')
    22   os.exit(1)
    23 end
