From e99627c4bdc8ab7995d55fd9d610a7a0e1a6be7b Mon Sep 17 00:00:00 2001 From: anshulguleria Date: Sun, 10 Jan 2016 20:19:01 +0530 Subject: [PATCH] Adds python syntax highlighting to the python sample code in readme --- README.rst | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/README.rst b/README.rst index 858b8f5..6946493 100644 --- a/README.rst +++ b/README.rst @@ -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"])