浏览代码

Added mg_send_file() to python binding

valenok 14 年之前
父节点
当前提交
81a5e3f342
共有 2 个文件被更改,包括 6 次插入0 次删除
  1. 3 0
      bindings/python/example.py
  2. 3 0
      bindings/python/mongoose.py

+ 3 - 0
bindings/python/example.py

@@ -39,6 +39,9 @@ def EventHandler(event, conn, info):
                '<input type="submit"/>'
                '</form>')
         return True
+    elif event == mongoose.NEW_REQUEST and info.uri == '/secret':
+        conn.send_file('/etc/passwd')
+        return True
     else:
         return False
 

+ 3 - 0
bindings/python/mongoose.py

@@ -110,6 +110,9 @@ class Connection(object):
         n = self.m.dll.mg_read(self.conn, buf, size)
         return n <= 0 and None or buf[:n]
 
+    def send_file(self, path):
+        self.m.dll.mg_send_file(self.conn, path)
+
 
 class Mongoose(object):
     """A wrapper class for Mongoose shared library."""