Skip to content

Commit 3b7e9f7

Browse files
committed
Create gh-pages branch via GitHub
1 parent e43e2a9 commit 3b7e9f7

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

index.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ <h3>No package installation, just one file, enjoy</h3>
4848
<pre><code>from SimpleWebSocketServer import WebSocket, SimpleWebSocketServer
4949

5050
class SimpleEcho(WebSocket):
51-
def __init__(self, server, sock, address):
52-
WebSocket.__init__(self, server, sock, address)
5351

5452
def handleMessage(self):
5553
if self.data == None:
@@ -95,7 +93,7 @@ <h4>TLS/SSL Example</h4>
9593
<pre><code>openssl req -new -x509 -days 365 -nodes -out cert.pem -keyout cert.pem
9694
</code></pre>
9795

98-
<p>2) Run the secure TSL/SSL server (in this case the cert.pem file is in the same directory)</p>
96+
<p>2) Run the secure TLS/SSL server (in this case the cert.pem file is in the same directory)</p>
9997

10098
<pre><code>python SimpleExampleServer.py --example chat --ssl 1 --cert ./cert.pem
10199
</code></pre>
@@ -130,7 +128,7 @@ <h4>TLS/SSL Example</h4>
130128
</ul><p>def sendMessage(buffer): send some text or binary data to the client endpoint</p>
131129

132130
<ul>
133-
<li>sending a buffer as str() will send a text based WebSocket frame otherwise binary</li>
131+
<li>str(buffer) will send a text based WebSocket frame otherwise binary</li>
134132
</ul>
135133
</section>
136134
</div>

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, enjoy</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.serveforever()\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<b>For the Programmers</b>\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 (STREAM, TEXT, BINARY)\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 - self.server.connections: map containing all the clients connected to the server\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\r\n","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, enjoy</h3>\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 \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.serveforever()\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 TLS/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<b>For the Programmers</b>\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 (STREAM, TEXT, BINARY)\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 - self.server.connections: map containing all the clients connected to the server\r\n\r\ndef sendMessage(buffer): send some text or binary data to the client endpoint\r\n - str(buffer) will send a text based WebSocket frame otherwise binary\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."}

0 commit comments

Comments
 (0)