websockets
Websockets is a solution for where we previously used long timeouts (long-hanging) for. If you come across the name "Comet" they mean opening a connection from the client to the server and letting it wait until the server has data ready for the client. Websockets turn this around so you can have your script call a websockets server , which in browser-client view is at the position of the client ! Almost all new browser version support websockets now.
mod_pywebsocket
Due to outdated examples, these scripts do not work. And since autobahn (see above) does work.. i see no use in investigating this further. Pending...
installation
A lot of implementations are around, but this will concentrate on apache2 and python.
| install | |
|---|---|
After this you can get documentation about the two versions : apache and standalone server :
demo
First an explanation of the python http server module :
SimpleHTTPServer
SimpleHTTPServer is a python module you can use to just server a directory directly onto a port.
| SimpleHTTPServer | |
|---|---|
-m means : search the python path for the module named and run it as a script. So the above line starts a 'simple' http server on port 8889 and server the files in the current directory. Short guide ? :
| SimpleHTTPServer | |
|---|---|
Browse to http://localhost:8889 , yes ... hello to you too. This is used in the following example as well
creating a standalone demo
Just do it in the test directory s before, but change index.html to :
Second create a server.py script containing :
Now startup the server like this :
| start | |
|---|---|