Python 如何自动刷新请求数据并刷新html中显示的变量?
所以基本上我使用python请求帖子来获取下一辆公交车到达时间的数据,然后我使用websocket和tornado制作一个html网页来显示我获取的数据 但是,我真的不知道如何自动刷新数据和html。我试着用这个:Python 如何自动刷新请求数据并刷新html中显示的变量?,python,html,websocket,refresh,tornado,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.IOLoo
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本地主机显示刷新值。您的缩进是怎么回事?为什么脚本中没有缩进
getETA()
?缩进是怎么回事?为什么脚本中没有缩进getETA()
?