Adds python syntax highlighting to the python sample code in readme
This commit is contained in:
33
README.rst
33
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.
|
Current implementation of websocket-client is using "CONNECT" method via proxy.
|
||||||
|
|
||||||
|
|
||||||
example::
|
example
|
||||||
|
..code:: python
|
||||||
|
|
||||||
import websocket
|
import websocket
|
||||||
ws = websocket.WebSocket()
|
ws = websocket.WebSocket()
|
||||||
@@ -55,7 +56,8 @@ example::
|
|||||||
Example
|
Example
|
||||||
=============
|
=============
|
||||||
|
|
||||||
Low Level API example::
|
Low Level API example
|
||||||
|
..code:: python
|
||||||
|
|
||||||
from websocket import create_connection
|
from websocket import create_connection
|
||||||
ws = create_connection("ws://echo.websocket.org/")
|
ws = create_connection("ws://echo.websocket.org/")
|
||||||
@@ -69,14 +71,16 @@ Low Level API example::
|
|||||||
|
|
||||||
If you want to customize socket options, set sockopt.
|
If you want to customize socket options, set sockopt.
|
||||||
|
|
||||||
sockopt example::
|
sockopt example
|
||||||
|
..code:: python
|
||||||
|
|
||||||
from websocket import create_connection
|
from websocket import create_connection
|
||||||
ws = create_connection("ws://echo.websocket.org/",
|
ws = create_connection("ws://echo.websocket.org/",
|
||||||
sockopt=((socket.IPPROTO_TCP, socket.TCP_NODELAY),))
|
sockopt=((socket.IPPROTO_TCP, socket.TCP_NODELAY),))
|
||||||
|
|
||||||
|
|
||||||
JavaScript websocket-like API example::
|
JavaScript websocket-like API example
|
||||||
|
..code:: python
|
||||||
|
|
||||||
import websocket
|
import websocket
|
||||||
import thread
|
import thread
|
||||||
@@ -120,17 +124,20 @@ How to disable ssl cert verification?
|
|||||||
|
|
||||||
Please set sslopt to {"cert_reqs": ssl.CERT_NONE}.
|
Please set sslopt to {"cert_reqs": ssl.CERT_NONE}.
|
||||||
|
|
||||||
WebSocketApp sample::
|
WebSocketApp sample
|
||||||
|
..code:: python
|
||||||
|
|
||||||
ws = websocket.WebSocketApp("wss://echo.websocket.org")
|
ws = websocket.WebSocketApp("wss://echo.websocket.org")
|
||||||
ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE})
|
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",
|
ws = websocket.create_connection("wss://echo.websocket.org",
|
||||||
sslopt={"cert_reqs": ssl.CERT_NONE})
|
sslopt={"cert_reqs": ssl.CERT_NONE})
|
||||||
|
|
||||||
WebSocket sample::
|
WebSocket sample
|
||||||
|
..code:: python
|
||||||
|
|
||||||
ws = websocket.WebSocket(sslopt={"cert_reqs": ssl.CERT_NONE})
|
ws = websocket.WebSocket(sslopt={"cert_reqs": ssl.CERT_NONE})
|
||||||
ws.connect("wss://echo.websocket.org")
|
ws.connect("wss://echo.websocket.org")
|
||||||
@@ -142,17 +149,20 @@ How to disable hostname verification.
|
|||||||
Please set sslopt to {"check_hostname": False}.
|
Please set sslopt to {"check_hostname": False}.
|
||||||
(since v0.18.0)
|
(since v0.18.0)
|
||||||
|
|
||||||
WebSocketApp sample::
|
WebSocketApp sample
|
||||||
|
..code:: python
|
||||||
|
|
||||||
ws = websocket.WebSocketApp("wss://echo.websocket.org")
|
ws = websocket.WebSocketApp("wss://echo.websocket.org")
|
||||||
ws.run_forever(sslopt={"check_hostname": False})
|
ws.run_forever(sslopt={"check_hostname": False})
|
||||||
|
|
||||||
create_connection sample::
|
create_connection sample
|
||||||
|
..code:: python
|
||||||
|
|
||||||
ws = websocket.create_connection("wss://echo.websocket.org",
|
ws = websocket.create_connection("wss://echo.websocket.org",
|
||||||
sslopt={"check_hostname": False})
|
sslopt={"check_hostname": False})
|
||||||
|
|
||||||
WebSocket sample::
|
WebSocket sample
|
||||||
|
..code:: python
|
||||||
|
|
||||||
ws = websocket.WebSocket(sslopt={"check_hostname": False})
|
ws = websocket.WebSocket(sslopt={"check_hostname": False})
|
||||||
ws.connect("wss://echo.websocket.org")
|
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.
|
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"])
|
ws = websocket.create_connection("ws://exapmle.com/websocket", subprotocols=["binary", "base64"])
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user