我正在编写网络服务器,它用某个文件夹中的文件列表来响应我:
test_folder = 'somefolder'
class TestLoader(object):
data = []
index = 0
def __init__(self, dir):
for sub in os.listdir(dir):
self.data.append(sub)
class TesterServer(object):
@cherrypy.expose
def index(self):
return "Test server works!"
@cherrypy.expose
def test(self):
tm = helper.TestManager(test_folder)
msg = ''
for i in tm:
msg += "\t %s" % i
return msg
cherrypy.quickstart(TesterServer())
问题是:当我重新加载页面时,数据被复制,而不是刷新。
IE:
页面加载:aaa bsbt bstat bump.py cherry.py helper.py
页面重新加载: aaa bsbt bstat bump.py cherry.py helper.py aaa bsbt bstat bump.py cherry.py helper.py
页面重新加载 #2: aaa bsbt bstat bump.py cherry.py helper.py aaa bsbt bstat bump.py cherry.py helper.py aaa bsbt bstat bump.py cherry.py helper.py
等等
我究竟做错了什么?提前致谢