Skip to content

Commit f296c3d

Browse files
committed
Create gh-pages branch via GitHub
1 parent 99974e8 commit f296c3d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ <h3>No package installation, just one file, so simple.</h3>
4040
<ul>
4141
<li>Hixie 76 (Safari and iPhone)</li>
4242
<li>RFC 6455 (All latest browsers)</li>
43-
<li>TSL/SSL</li>
43+
<li>TLS/SSL</li>
4444
</ul><h4>A Simple Echo Server Example</h4>
4545

4646
<p>1) Write the client code by extending WebSocket</p>
@@ -88,7 +88,7 @@ <h4>Want to get up and running faster?</h4>
8888
python SimpleExampleServer.py --example chat
8989
</code></pre>
9090

91-
<h4>TSL/SSL Example</h4>
91+
<h4>TLS/SSL Example</h4>
9292

9393
<p>1) Generate a certificate with key</p>
9494

params.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"name":"SimpleWebSocketServer","tagline":"","body":"<h2>A very simple WebSocket Server written in Python</h2>\r\n<h3>No package installation, just one file, so simple.</h3>\r\n\r\n\r\nSupports\r\n - Hixie 76 (Safari and iPhone)\r\n - RFC 6455 (All latest browsers)\r\n - TSL/SSL\r\n\r\n<h4>A Simple Echo Server Example</h4>\r\n\r\n1) Write the client code by extending WebSocket\r\n\r\n from SimpleWebSocketServer import WebSocket, SimpleWebSocketServer\r\n \r\n class SimpleEcho(WebSocket):\r\n def __init__(self, server, sock, address):\r\n WebSocket.__init__(self, server, sock, address)\r\n \r\n def handleMessage(self):\r\n if self.data == None:\r\n self.data = ''\r\n \r\n # echo it back to client\r\n self.sendMessage(str(self.data))\r\n \r\n def handleConnected(self):\r\n print self.address, 'connected'\r\n \r\n def handleClose(self):\r\n print self.address, 'closed'\r\n\r\n server = SimpleWebSocketServer('', 8000, SimpleEcho)\r\n server.serverforever()\r\n \r\n2) Run your code\r\n\r\n3) Open up <i>websocket.html</i> and connect to the server\r\n\r\n<h4>Want to get up and running faster?</h4>\r\n\r\nThere is an example which provides a simple echo and chat server\r\n\r\nEcho Server\r\n\r\n # echo server\r\n python SimpleExampleServer.py --example echo\r\n\r\nChat Server (open up multiple <i>websocket.html</i> files)\r\n \r\n # chat server\r\n python SimpleExampleServer.py --example chat\r\n\r\n\r\n<h4>TSL/SSL Example</h4>\r\n\r\n1) Generate a certificate with key\r\n\r\n openssl req -new -x509 -days 365 -nodes -out cert.pem -keyout cert.pem\r\n \r\n2) Run the secure TSL/SSL server (in this case the cert.pem file is in the same directory)\r\n\r\n python SimpleExampleServer.py --example chat --ssl 1 --cert ./cert.pem\r\n \r\n3) Offer the certificate to the browser by serving <i>websocket.html</i> through https. \r\nThe HTTPS server will look for cert.pem in the local directory. \r\nEnsure the <i>websocket.html</i> is also in the same directory to where the server is run. \r\n\r\n sudo python SimpleHTTPSServer.py\r\n\r\n4) Open a web browser to: <i>https://localhost:443/websocket.html</i>\r\n\r\n5) Change <i>ws://localhost:8000/</i> to <i>wss://localhost:8000</i> and click connect. \r\n\r\nNote: if you are having problems connecting, ensure that the certificate is added in your browser against the exception https://localhost:8000 or whatever host:port pair you want to connect to. \r\n\r\n<h4>For the Programmers</h4>\r\n\r\ndef handleConnected(): called when handskake is complete\r\n\r\ndef handleClose(): called when the endpoint is closed or there is an error\r\n\r\ndef handleMessage(): gets called when there is an incoming message from the client endpoint\r\n - self.opcode: the WebSocket frame type (TEXT, BINARY, PING, PONG)\r\n - self.data: bytearray payload or None if there was no payload\r\n - self.address: address port tuple of the endpoint\r\n - self.request: HTTP details from the WebSocket handshake (refer to BaseHTTPRequestHandler for its use)\r\n\r\ndef sendMessage(buffer): send some text or binary data to the client endpoint\r\n - sending a buffer as str() will send a text based WebSocket frame otherwise binary","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."}
1+
{"name":"SimpleWebSocketServer","tagline":"","body":"<h2>A very simple WebSocket Server written in Python</h2>\r\n<h3>No package installation, just one file, so simple.</h3>\r\n\r\n\r\nSupports\r\n - Hixie 76 (Safari and iPhone)\r\n - RFC 6455 (All latest browsers)\r\n - TLS/SSL\r\n\r\n<h4>A Simple Echo Server Example</h4>\r\n\r\n1) Write the client code by extending WebSocket\r\n\r\n from SimpleWebSocketServer import WebSocket, SimpleWebSocketServer\r\n \r\n class SimpleEcho(WebSocket):\r\n def __init__(self, server, sock, address):\r\n WebSocket.__init__(self, server, sock, address)\r\n \r\n def handleMessage(self):\r\n if self.data == None:\r\n self.data = ''\r\n \r\n # echo it back to client\r\n self.sendMessage(str(self.data))\r\n \r\n def handleConnected(self):\r\n print self.address, 'connected'\r\n \r\n def handleClose(self):\r\n print self.address, 'closed'\r\n\r\n server = SimpleWebSocketServer('', 8000, SimpleEcho)\r\n server.serverforever()\r\n \r\n2) Run your code\r\n\r\n3) Open up <i>websocket.html</i> and connect to the server\r\n\r\n<h4>Want to get up and running faster?</h4>\r\n\r\nThere is an example which provides a simple echo and chat server\r\n\r\nEcho Server\r\n\r\n # echo server\r\n python SimpleExampleServer.py --example echo\r\n\r\nChat Server (open up multiple <i>websocket.html</i> files)\r\n \r\n # chat server\r\n python SimpleExampleServer.py --example chat\r\n\r\n\r\n<h4>TLS/SSL Example</h4>\r\n\r\n1) Generate a certificate with key\r\n\r\n openssl req -new -x509 -days 365 -nodes -out cert.pem -keyout cert.pem\r\n \r\n2) Run the secure TSL/SSL server (in this case the cert.pem file is in the same directory)\r\n\r\n python SimpleExampleServer.py --example chat --ssl 1 --cert ./cert.pem\r\n \r\n3) Offer the certificate to the browser by serving <i>websocket.html</i> through https. \r\nThe HTTPS server will look for cert.pem in the local directory. \r\nEnsure the <i>websocket.html</i> is also in the same directory to where the server is run. \r\n\r\n sudo python SimpleHTTPSServer.py\r\n\r\n4) Open a web browser to: <i>https://localhost:443/websocket.html</i>\r\n\r\n5) Change <i>ws://localhost:8000/</i> to <i>wss://localhost:8000</i> and click connect. \r\n\r\nNote: if you are having problems connecting, ensure that the certificate is added in your browser against the exception https://localhost:8000 or whatever host:port pair you want to connect to. \r\n\r\n<h4>For the Programmers</h4>\r\n\r\ndef handleConnected(): called when handskake is complete\r\n\r\ndef handleClose(): called when the endpoint is closed or there is an error\r\n\r\ndef handleMessage(): gets called when there is an incoming message from the client endpoint\r\n - self.opcode: the WebSocket frame type (TEXT, BINARY, PING, PONG)\r\n - self.data: bytearray payload or None if there was no payload\r\n - self.address: address port tuple of the endpoint\r\n - self.request: HTTP details from the WebSocket handshake (refer to BaseHTTPRequestHandler for its use)\r\n\r\ndef sendMessage(buffer): send some text or binary data to the client endpoint\r\n - sending a buffer as str() will send a text based WebSocket frame otherwise binary","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."}

0 commit comments

Comments
 (0)