@@ -14,7 +14,8 @@ Source is available on
1414
1515You'll need to run ` python virtualenv ` .
1616Then
17- ``` commandline
17+
18+ ```
1819bin/pip install -r requirements.txt
1920bin/python setup.py develop
2021```
@@ -29,6 +30,7 @@ object. This object has a .toJSON() method that will return a JSON object that c
2930and push data.
3031
3132As illustration, a ` subscription_info ` object may look like:
33+
3234``` json
3335{"endpoint" : " https://updates.push.services.mozilla.com/push/v1/gAA..." , "keys" : {"auth" : " k8J..." , "p256dh" : " BOr..." }}
3436```
@@ -44,14 +46,15 @@ In many cases, your code will be sending a single message to many
4446recipients. There's a "One Call" function which will make things
4547easier.
4648
47- ``` pythonstub
48- from pywebpush import webpush
49+ ``` python
50+ from pywebpush import webpush
4951
50- webpush(subscription_info,
51- data,
52- vapid_private_key="Private Key or File Path[1]",
53- vapid_claims={"sub": "mailto:YourEmailAddress"})
52+ webpush(subscription_info,
53+ data,
54+ vapid_private_key = " Private Key or File Path[1]" ,
55+ vapid_claims = {" sub" : " mailto:YourEmailAddress" })
5456```
57+
5558This will encode ` data ` , add the appropriate VAPID auth headers if required and send it to the push server identified
5659in the ` subscription_info ` block.
5760
@@ -74,13 +77,14 @@ pywebpush will attempt to auto-fill from the `endpoint`.
7477a base64 encoded DER formatted private key, or the path to an OpenSSL exported private key file.
7578
7679e.g. the output of:
77- ``` commandline
80+
81+ ```
7882openssl ecparam -name prime256v1 -genkey -noout -out private_key.pem
7983```
8084
8185** Example**
8286
83- ``` pythonstub
87+ ``` python
8488from pywebpush import webpush, WebPushException
8589
8690try :
@@ -133,7 +137,8 @@ named `encrpypted.data`. This command is meant to be used for debugging purposes
133137** Example**
134138
135139to send from Chrome using the old GCM mode:
136- ``` pythonstub
140+
141+ ``` python
137142WebPusher(subscription_info).send(data, headers, ttl, gcm_key)
138143```
139144
@@ -149,7 +154,7 @@ Encode the `data` for future use. On error, returns a `WebPushException`
149154
150155** Example**
151156
152- ``` pythonstub
157+ ``` python
153158encoded_data = WebPush(subscription_info).encode(data)
154159```
155160
0 commit comments