Merge pull request #232 from anshulguleria/syntax-highlighting

Adds python syntax highlighting to the python sample code in readme
This commit is contained in:
liris 2016-02-04 16:22:18 +09:00
commit f482a63b10
1 changed files with 22 additions and 11 deletions

View File

@ -43,7 +43,8 @@ Default squid setting is "ALLOWED TO CONNECT ONLY HTTPS PORT".
Current implementation of websocket-client is using "CONNECT" method via proxy.
example::
example
..code:: python
import websocket
ws = websocket.WebSocket()
@ -55,7 +56,8 @@ example::
Example
=============
Low Level API example::
Low Level API example
..code:: python
from websocket import create_connection
ws = create_connection("ws://echo.websocket.org/")
@ -69,14 +71,16 @@ Low Level API example::
If you want to customize socket options, set sockopt.
sockopt example::
sockopt example
..code:: python
from websocket import create_connection
ws = create_connection("ws://echo.websocket.org/",
sockopt=((socket.IPPROTO_TCP, socket.TCP_NODELAY),))
JavaScript websocket-like API example::
JavaScript websocket-like API example
..code:: python
import websocket
import thread
@ -120,17 +124,20 @@ How to disable ssl cert verification?
Please set sslopt to {"cert_reqs": ssl.CERT_NONE}.
WebSocketApp sample::
WebSocketApp sample
..code:: python
ws = websocket.WebSocketApp("wss://echo.websocket.org")
ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE})
create_connection sample::
create_connection sample
..code:: python
ws = websocket.create_connection("wss://echo.websocket.org",
sslopt={"cert_reqs": ssl.CERT_NONE})
WebSocket sample::
WebSocket sample
..code:: python
ws = websocket.WebSocket(sslopt={"cert_reqs": ssl.CERT_NONE})
ws.connect("wss://echo.websocket.org")
@ -142,17 +149,20 @@ How to disable hostname verification.
Please set sslopt to {"check_hostname": False}.
(since v0.18.0)
WebSocketApp sample::
WebSocketApp sample
..code:: python
ws = websocket.WebSocketApp("wss://echo.websocket.org")
ws.run_forever(sslopt={"check_hostname": False})
create_connection sample::
create_connection sample
..code:: python
ws = websocket.create_connection("wss://echo.websocket.org",
sslopt={"check_hostname": False})
WebSocket sample::
WebSocket sample
..code:: python
ws = websocket.WebSocket(sslopt={"check_hostname": False})
ws.connect("wss://echo.websocket.org")
@ -170,7 +180,8 @@ Sub Protocols.
The server needs to support sub protocols, please set the subprotocol like this.
Subprotocol sample::
Subprotocol sample
..code:: python
ws = websocket.create_connection("ws://exapmle.com/websocket", subprotocols=["binary", "base64"])