Skip to content

Commit 5c8cfcb

Browse files
committed
修改例子代码
1 parent ad9ee1e commit 5c8cfcb

File tree

6 files changed

+18
-11
lines changed

6 files changed

+18
-11
lines changed

demo/example.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import sys
44
sys.dont_write_bytecode = True
5+
sys.path.insert(0, '..')
56

67
import litefs
78
litefs = litefs.Litefs(

demo/site/environ.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def handler(self):
2+
return self.environ
File renamed without changes.

demo/site/index.html.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
#-*- coding: utf-8 -*-
2+
13
def handler(self):
24
return '''
3-
<a href="helloword">helloword</a>
4-
<a href="pathinfo">pathinfo</a>
5-
<a href="upload.html">upload.html</a>
6-
<a href="form.html">form.html</a>
5+
<ul>
6+
<li><a href="helloworld">Hello World</a></li>
7+
<li><a href="pathinfo">环境变量 PATH_INFO</a></li>
8+
<li><a href="upload.html">文件上传</a></li>
9+
<li><a href="form.html">表单数据</a></li>
10+
</ul>
711
'''

demo/site/pathinfo.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

litefs.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import re
2121
import sys
2222
import _socket as socket
23-
from collections import deque
23+
from collections import deque, Iterable
2424
from Cookie import SimpleCookie
2525
from cStringIO import StringIO
2626
from errno import ENOTCONN, EMFILE, EWOULDBLOCK, EAGAIN, EPIPE
@@ -695,12 +695,16 @@ def _finish(self, content):
695695
rw.write(self._buffers.getvalue())
696696
if isinstance(content, basestring):
697697
rw.write(content)
698-
else:
698+
elif isinstance(content, dict):
699+
rw.write(repr(content))
700+
elif isinstance(content, Iterable):
699701
for s in content:
700702
if isinstance(s, basestring):
701703
rw.write(s)
702704
else:
703-
rw.write('%r' % s)
705+
rw.write(repr(s))
706+
else:
707+
rw.write(repr(s))
704708
try:
705709
rw.close()
706710
except:

0 commit comments

Comments
 (0)