如何自动刷新请求数据和刷新html中显示的变量?

时间:2015-10-27 07:54:43

标签: python html websocket refresh tornado

所以基本上我使用python请求帖子来获取有关下一班巴士到达时间的数据,然后我使用websocket和tornado制作一个html网页来显示我抓住的数据。

但是,我真的不知道如何自动刷新数据和HTML。我试着用这个:

import threading
def getETA():
threading.Timer(5.0, getETA).start()

... python文件以

结尾
if __name__ == "__main__":
  app.listen(8888)
  ioloop.IOLoop.instance().start()
getETA()

所以代码运行并显示此错误

Exception in thread Thread-25:
Traceback (most recent call last):
 File "C:\Python34\lib\threading.py", line 920, in _bootstrap_inner
   self.run()
 File "C:\Python34\lib\threading.py", line 1186, in run
   self.function(*self.args, **self.kwargs)
 File "C:\Users\Tan\Desktop\DIP\DIP WEB INTERFACE\testing.py", line 183, in getETA
   app.listen(8888)
 File "C:\Python34\lib\site-packages\tornado\web.py", line 1788, in listen
   server.listen(port, address)
 File "C:\Python34\lib\site-packages\tornado\tcpserver.py", line 126, in listen
   sockets = bind_sockets(port, address=address)
 File "C:\Python34\lib\site-packages\tornado\netutil.py", line 187, in bind_sockets
   sock.bind(sockaddr)
OSError: [WinError 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted

请建议正确的方式或其他方法让我的html本地主机显示刷新值。

0 个答案:

没有答案