我有一个在bottle.py 上运行的网络界面。如果发生某些事情,我不想做的是在网站上弹出一个小通知。
我不确定如何告诉客户发生了什么事。
我应该只投票还是有更优雅的方式?
因为我希望通知及时出现,所以我必须至少每秒轮询一次,这对于网络服务器来说听起来像是很多负载,只是为了通知。
As mentionned by Joe Doherty, websockets is a solution. You may be ineterested by bottle-tornadosocket in order to run bottle on top of the Tornado web server. I didn't try myself but it looks interesting.
However, websocket may not be available for all browsers. Using long-polling is another solution. In this case, I would recommend to look at tornadio which should be possible to use together with bottle.
I hope it helps