浏览代码

Add documentation on the working path used for Lua scripts

Document that Lua uses the current working path of the process.
See also issue #56.
bel2125 10 年之前
父节点
当前提交
5e9859510b
共有 3 个文件被更改,包括 8 次插入1 次删除
  1. 4 1
      docs/UserManual.md
  2. 2 0
      test/page.lp
  3. 2 0
      test/page.lua

+ 4 - 1
docs/UserManual.md

@@ -416,7 +416,10 @@ Note that this example uses function `mg.write()`, which sends data to the
 web client. Using `mg.write()` is the way to generate web content from inside
 Lua code. In addition to `mg.write()`, all standard Lua library functions
 are accessible from the Lua code (please check the reference manual for
-details). Information on the request is available in the `mg.request_info`
+details). Lua functions working on files (e.g., `io.open`) use a path
+relative to the working path of the civetweb process. The web server content
+is located in the path `mg.document_root`.
+Information on the request is available in the `mg.request_info`
 object, like the request method, all HTTP headers, etcetera.
 
 [page2.lua](https://github.com/bel2125/civetweb/blob/master/test/page2.lua)

+ 2 - 0
test/page.lp

@@ -28,6 +28,8 @@ The following features are available:
 <?
   -- Open database
   local db = sqlite3.open('requests.db')
+  -- Note that the data base is located in the current working directory
+  -- of the process if no other path is given here.
 
   -- Setup a trace callback, to show SQL statements we'll be executing.
   -- db:trace(function(data, sql) mg.write('Executing: ', sql: '\n') end, nil)

+ 2 - 0
test/page.lua

@@ -26,6 +26,8 @@ mg.write("<p>Database example:\r\n<pre>\r\n")
 
   -- Open database
   local db = sqlite3.open('requests.db')
+  -- Note that the data base is located in the current working directory
+  -- of the process if no other path is given here.
 
   -- Setup a trace callback, to show SQL statements we'll be executing.
   -- db:trace(function(data, sql) mg.write('Executing: ', sql: '\n') end, nil)