javascript - CherryPy Real-Time Web Application -


i've inherited web application running cherrypy web server. need implement user interface automatically update data server. right solution use javascript polling. while works, feels dirty.

i love use socket.io, cannot find support doing cherrypy backend. 1 have insight approach?

websockets great too, except need support ie. there non-flash fallbacks ie? , websocket support in cherrypy have found ws4py, don't know have experience using it.

are there comet implementations cherrypy.

for it's worth have been scouring internet last few days looking solutions, haven't found "this can do" results.

is possible , make sense install node.js , have client ui communicate node.js server talks cherrypy? or wasteful?

thanks!

real-time cherrypy easy way

this can do - in order publish real-time data web-client user send asynchronous updates, following.

pip install

pip install cherrypy pip install pubnub 

cherrypy hello world

import cherrypy  pubnub import pubnub pubnub = pubnub( "demo", "demo" )  class helloworld(object):     def index(self):         ## put following line in place when want send         ## push signal web user.         pubnub.publish({             "channel" : "cherrypy_example", ## channel name             "message" : "hi!"         })          ## if want return details.         return "message sent"      index.exposed = true 

next, paste following code web html/javascript page:

<script src="https://pubnub.a.ssl.fastly.net/pubnub-3.4.3.min.js"></script> <script>(function(){      var pubnub = pubnub.init({         subscribe_key : 'demo',         ssl           : true     });      pubnub.subscribe({         channel : 'cherrypy_example',  // channel name         message : function(message) {             alert(json.stringify(message));         }     });  })();</script> 

learn more details here python pubnub lib - https://github.com/pubnub/pubnub-api/tree/master/python#you-must-have-a-pubnub-account-to-use-the-api

important note: free version. the python lib not secure in free version. reocmmend setup paid version of account visiting: https://admin.pubnub.com/ , setting secured python pip lib replacing "demo" key settings provided secure secret keys.


Comments