【发布时间】:2014-09-07 11:38:56
【问题描述】:
网页上有显示当前时间的代码:
from twisted.internet import reactor
from twisted.web.server import Site
from twisted.web.resource import Resource
import time
class ClockPage(Resource):
isLeaf = True
def render_GET(self, request):
return "<html><body>%s</body></html>" % (time.ctime(),)
resource = ClockPage()
factory = Site(resource)
reactor.listenTCP(8880, factory)
reactor.run()
如何修改它以每秒更新输出时间而不重新加载页面?我应该使用 javascript(ajax/jquery) 以固定间隔发送 GET 请求还是可以在 python 代码中执行?
谢谢。
【问题讨论】: